3 * Copyright 2015 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H
20 #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H
22 #include <grpc/support/port_platform.h>
24 #include "src/core/lib/transport/transport.h"
26 struct grpc_chttp2_incoming_metadata_buffer {
27 explicit grpc_chttp2_incoming_metadata_buffer(grpc_core::Arena* arena)
29 grpc_metadata_batch_init(&batch);
30 batch.deadline = GRPC_MILLIS_INF_FUTURE;
32 ~grpc_chttp2_incoming_metadata_buffer() {
33 grpc_metadata_batch_destroy(&batch);
36 static constexpr size_t kPreallocatedMDElem = 10;
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;
46 void grpc_chttp2_incoming_metadata_buffer_publish(
47 grpc_chttp2_incoming_metadata_buffer* buffer, grpc_metadata_batch* batch);
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);
58 #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */