Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc / deps / grpc / src / core / ext / transport / chttp2 / transport / incoming_metadata.h
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18
19 #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H
20 #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H
21
22 #include <grpc/support/port_platform.h>
23
24 #include "src/core/lib/transport/transport.h"
25
26 struct grpc_chttp2_incoming_metadata_buffer {
27   explicit grpc_chttp2_incoming_metadata_buffer(grpc_core::Arena* arena)
28       : arena(arena) {
29     grpc_metadata_batch_init(&batch);
30     batch.deadline = GRPC_MILLIS_INF_FUTURE;
31   }
32   ~grpc_chttp2_incoming_metadata_buffer() {
33     grpc_metadata_batch_destroy(&batch);
34   }
35
36   static constexpr size_t kPreallocatedMDElem = 10;
37
38   grpc_core::Arena* arena;
39   size_t size = 0;   // total size of metadata.
40   size_t count = 0;  // minimum of count of metadata and kPreallocatedMDElem.
41   // These preallocated mdelems are used while count < kPreallocatedMDElem.
42   grpc_linked_mdelem preallocated_mdelems[kPreallocatedMDElem];
43   grpc_metadata_batch batch;
44 };
45
46 void grpc_chttp2_incoming_metadata_buffer_publish(
47     grpc_chttp2_incoming_metadata_buffer* buffer, grpc_metadata_batch* batch);
48
49 grpc_error* grpc_chttp2_incoming_metadata_buffer_add(
50     grpc_chttp2_incoming_metadata_buffer* buffer,
51     grpc_mdelem elem) GRPC_MUST_USE_RESULT;
52 grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add(
53     grpc_chttp2_incoming_metadata_buffer* buffer,
54     grpc_mdelem elem) GRPC_MUST_USE_RESULT;
55 void grpc_chttp2_incoming_metadata_buffer_set_deadline(
56     grpc_chttp2_incoming_metadata_buffer* buffer, grpc_millis deadline);
57
58 #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */