hpack_encoder_table.h
Go to the documentation of this file.
1 // Copyright 2021 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_TABLE_H
16 #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_TABLE_H
17 
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 
23 #include "absl/container/inlined_vector.h"
24 
26 
27 namespace grpc_core {
28 
29 // Tracks the values available in the remote HPACK header table, and their
30 // sizes.
32  public:
34 
35  static constexpr size_t MaxEntrySize() { return 65535; }
36 
37  // Reserve space in table for the new element, evict entries if needed.
38  // Return the new index of the element. Return 0 to indicate not adding to
39  // table.
40  uint32_t AllocateIndex(size_t element_size);
41  // Set the maximum table size. Return true if it changed.
42  bool SetMaxSize(uint32_t max_table_size);
43  // Get the current max table size
44  uint32_t max_size() const { return max_table_size_; }
45  // Get the current table size
47 
48  // Convert an element index into a dynamic index
52  }
53  // Check if an element index is convertable to a dynamic index
55  return index > tail_remote_index_;
56  }
57 
58  private:
59  void EvictOne();
61 
62  // one before the lowest usable table index
67  // The size of each element in the HPACK table.
70 };
71 
72 } // namespace grpc_core
73 
74 #endif // GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_TABLE_H
capacity
uint16_t capacity
Definition: protobuf/src/google/protobuf/descriptor.cc:948
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::HPackEncoderTable::tail_remote_index_
uint32_t tail_remote_index_
Definition: hpack_encoder_table.h:63
grpc_core::HPackEncoderTable
Definition: hpack_encoder_table.h:31
grpc_core::HPackEncoderTable::AllocateIndex
uint32_t AllocateIndex(size_t element_size)
Definition: hpack_encoder_table.cc:26
grpc_core::HPackEncoderTable::max_size
uint32_t max_size() const
Definition: hpack_encoder_table.h:44
grpc_core::HPackEncoderTable::EvictOne
void EvictOne()
Definition: hpack_encoder_table.cc:69
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
grpc_core::HPackEncoderTable::table_elems_
uint32_t table_elems_
Definition: hpack_encoder_table.h:65
grpc_core::HPackEncoderTable::table_size_
uint32_t table_size_
Definition: hpack_encoder_table.h:66
grpc_core::HPackEncoderTable::MaxEntrySize
static constexpr size_t MaxEntrySize()
Definition: hpack_encoder_table.h:35
grpc_core::HPackEncoderTable::elem_size_
absl::InlinedVector< uint16_t, hpack_constants::kInitialTableEntries > elem_size_
Definition: hpack_encoder_table.h:69
stdint.h
grpc_core::hpack_constants::kInitialTableEntries
static constexpr uint32_t kInitialTableEntries
Definition: hpack_constants.h:36
grpc_core::hpack_constants::kLastStaticEntry
static constexpr uint32_t kLastStaticEntry
Definition: hpack_constants.h:30
grpc_core::HPackEncoderTable::SetMaxSize
bool SetMaxSize(uint32_t max_table_size)
Definition: hpack_encoder_table.cc:52
grpc_core::HPackEncoderTable::max_table_size_
uint32_t max_table_size_
Definition: hpack_encoder_table.h:64
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
hpack_constants.h
grpc_core::HPackEncoderTable::DynamicIndex
uint32_t DynamicIndex(uint32_t index) const
Definition: hpack_encoder_table.h:49
grpc_core::HPackEncoderTable::Rebuild
void Rebuild(uint32_t capacity)
Definition: hpack_encoder_table.cc:79
grpc_core::HPackEncoderTable::ConvertableToDynamicIndex
bool ConvertableToDynamicIndex(uint32_t index) const
Definition: hpack_encoder_table.h:54
grpc_core::hpack_constants::kInitialTableSize
static constexpr uint32_t kInitialTableSize
Definition: hpack_constants.h:27
absl::InlinedVector< uint16_t, hpack_constants::kInitialTableEntries >
grpc_core::HPackEncoderTable::HPackEncoderTable
HPackEncoderTable()
Definition: hpack_encoder_table.h:33
grpc_core::HPackEncoderTable::test_only_table_size
uint32_t test_only_table_size() const
Definition: hpack_encoder_table.h:46
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:13