proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
HeaderTable.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015-present, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
*/
10
#pragma once
11
12
#include <list>
13
#include <
proxygen/lib/http/codec/compress/HPACKHeader.h
>
14
#include <string>
15
#include <unordered_map>
16
#include <unordered_set>
17
#include <vector>
18
19
namespace
proxygen
{
20
26
class
HeaderTable
{
27
public
:
28
using
names_map
= std::unordered_map<HPACKHeaderName, std::list<uint32_t>>;
29
30
explicit
HeaderTable
(
uint32_t
capacityVal) {
31
init
(capacityVal);
32
}
33
34
virtual
~HeaderTable
() {}
35
HeaderTable
(
const
HeaderTable
&) =
delete
;
36
HeaderTable
&
operator=
(
const
HeaderTable
&) =
delete
;
37
43
virtual
bool
add
(
HPACKHeader
header);
44
50
uint32_t
getIndex
(
const
HPACKHeader
& header)
const
;
51
57
const
HPACKHeader
&
getHeader
(
uint32_t
index)
const
;
58
62
bool
isValid
(
uint32_t
index)
const
;
63
67
bool
hasName
(
const
HPACKHeaderName
& headerName);
68
72
const
names_map
&
names
()
const
{
73
return
names_
;
74
}
75
81
uint32_t
nameIndex
(
const
HPACKHeaderName
& headerName)
const
;
82
86
uint32_t
capacity
()
const
{
87
return
capacity_
;
88
}
89
94
uint32_t
getMaxTableLength
(
uint32_t
capacityVal);
95
100
virtual
bool
setCapacity
(
uint32_t
capacity
);
101
105
uint32_t
size
()
const
{
106
return
size_
;
107
}
108
112
uint32_t
bytes
()
const
{
113
return
bytes_
;
114
}
115
119
size_t
length
()
const
{
120
return
table_
.size();
121
}
122
123
bool
operator==
(
const
HeaderTable
& other)
const
;
124
128
static
uint32_t
toExternal
(
uint32_t
head,
uint32_t
length
,
129
uint32_t
internalIndex);
130
131
static
uint32_t
toInternal
(
uint32_t
head,
uint32_t
length,
132
uint32_t
externalIndex);
133
134
protected
:
138
void
init
(
uint32_t
capacityVal);
139
140
/*
141
* Increase table length to newLength
142
*/
143
virtual
void
increaseTableLengthTo
(
uint32_t
newLength);
144
145
virtual
void
resizeTable
(
uint32_t
newLength);
146
147
virtual
void
updateResizedTable
(
uint32_t
oldTail,
uint32_t
oldLength,
148
uint32_t
newLength);
149
155
virtual
uint32_t
removeLast
();
156
160
void
reset
();
161
165
virtual
uint32_t
evict
(
uint32_t
needed,
uint32_t
desiredCapacity);
166
170
uint32_t
next
(
uint32_t
i
)
const
;
171
175
uint32_t
tail
()
const
;
176
180
uint32_t
toExternal
(
uint32_t
internalIndex)
const
;
181
185
uint32_t
toInternal
(
uint32_t
externalIndex)
const
;
186
187
uint32_t
capacity_
{0};
188
uint32_t
bytes_
{0};
// size in bytes of the current entries
189
std::vector<HPACKHeader>
table_
;
190
191
uint32_t
size_
{0};
// how many entries we have in the table
192
uint32_t
head_
{0};
// points to the first element of the ring
193
194
names_map
names_
;
195
196
private
:
197
/*
198
* Shared implementation for getIndex and nameIndex
199
*/
200
uint32_t
getIndexImpl
(
const
HPACKHeaderName
& header,
201
const
folly::fbstring
&
value
,
202
bool
nameOnly)
const
;
203
};
204
205
std::ostream&
operator<<
(std::ostream& os,
const
HeaderTable
& table);
206
207
}
i
i
Definition:
gtest_output_test_golden_lin.txt:83
proxygen::HeaderTable::capacity
uint32_t capacity() const
Definition:
HeaderTable.h:86
proxygen::HeaderTable::evict
virtual uint32_t evict(uint32_t needed, uint32_t desiredCapacity)
Definition:
HeaderTable.cpp:196
proxygen::operator<<
std::ostream & operator<<(std::ostream &os, const HeaderTable &table)
Definition:
HeaderTable.cpp:254
proxygen::HeaderTable::operator==
bool operator==(const HeaderTable &other) const
Definition:
HeaderTable.cpp:244
proxygen::HeaderTable::hasName
bool hasName(const HPACKHeaderName &headerName)
Definition:
HeaderTable.cpp:84
proxygen::HeaderTable::getMaxTableLength
uint32_t getMaxTableLength(uint32_t capacityVal)
Definition:
HeaderTable.cpp:98
folly::basic_fbstring< char >
proxygen::HeaderTable
Definition:
HeaderTable.h:26
proxygen::HeaderTable::getHeader
const HPACKHeader & getHeader(uint32_t index) const
Definition:
HeaderTable.cpp:93
proxygen::HeaderTable::head_
uint32_t head_
Definition:
HeaderTable.h:192
proxygen::HeaderTable::bytes
uint32_t bytes() const
Definition:
HeaderTable.h:112
proxygen::HeaderTable::isValid
bool isValid(uint32_t index) const
Definition:
HeaderTable.cpp:204
proxygen::HPACKHeaderName
Definition:
HPACKHeaderName.h:29
HPACKHeader.h
proxygen::HeaderTable::operator=
HeaderTable & operator=(const HeaderTable &)=delete
proxygen::HeaderTable::next
uint32_t next(uint32_t i) const
Definition:
HeaderTable.cpp:213
proxygen::HeaderTable::toExternal
static uint32_t toExternal(uint32_t head, uint32_t length, uint32_t internalIndex)
Definition:
HeaderTable.cpp:228
proxygen::HeaderTable::getIndexImpl
uint32_t getIndexImpl(const HPACKHeaderName &header, const folly::fbstring &value, bool nameOnly) const
Definition:
HeaderTable.cpp:67
proxygen::HeaderTable::increaseTableLengthTo
virtual void increaseTableLengthTo(uint32_t newLength)
Definition:
HeaderTable.cpp:159
proxygen::HPACKHeader
Definition:
HPACKHeader.h:20
proxygen::HeaderTable::bytes_
uint32_t bytes_
Definition:
HeaderTable.h:188
proxygen::HeaderTable::reset
void reset()
Definition:
HeaderTable.cpp:127
proxygen::HeaderTable::toInternal
static uint32_t toInternal(uint32_t head, uint32_t length, uint32_t externalIndex)
Definition:
HeaderTable.cpp:237
proxygen::HeaderTable::length
size_t length() const
Definition:
HeaderTable.h:119
value
static const char *const value
Definition:
Conv.cpp:50
proxygen::HeaderTable::~HeaderTable
virtual ~HeaderTable()
Definition:
HeaderTable.h:34
proxygen::HeaderTable::nameIndex
uint32_t nameIndex(const HPACKHeaderName &headerName) const
Definition:
HeaderTable.cpp:88
proxygen::HeaderTable::names
const names_map & names() const
Definition:
HeaderTable.h:72
proxygen::HeaderTable::updateResizedTable
virtual void updateResizedTable(uint32_t oldTail, uint32_t oldLength, uint32_t newLength)
Definition:
HeaderTable.cpp:190
proxygen::HeaderTable::removeLast
virtual uint32_t removeLast()
Definition:
HeaderTable.cpp:105
proxygen::HeaderTable::init
void init(uint32_t capacityVal)
Definition:
HeaderTable.cpp:20
proxygen::HeaderTable::resizeTable
virtual void resizeTable(uint32_t newLength)
Definition:
HeaderTable.cpp:186
proxygen::HeaderTable::capacity_
uint32_t capacity_
Definition:
HeaderTable.h:187
proxygen::HeaderTable::names_map
std::unordered_map< HPACKHeaderName, std::list< uint32_t >> names_map
Definition:
HeaderTable.h:28
proxygen
Definition:
ExMessageHandler.h:14
uint32_t
uint32_t
Definition:
ConstexprMathBenchmark.cpp:186
proxygen::HeaderTable::table_
std::vector< HPACKHeader > table_
Definition:
HeaderTable.h:189
proxygen::HeaderTable::setCapacity
virtual bool setCapacity(uint32_t capacity)
Definition:
HeaderTable.cpp:136
proxygen::HeaderTable::size
uint32_t size() const
Definition:
HeaderTable.h:105
proxygen::HeaderTable::tail
uint32_t tail() const
Definition:
HeaderTable.cpp:217
proxygen::HeaderTable::names_
names_map names_
Definition:
HeaderTable.h:194
proxygen::HeaderTable::getIndex
uint32_t getIndex(const HPACKHeader &header) const
Definition:
HeaderTable.cpp:63
proxygen::HeaderTable::HeaderTable
HeaderTable(uint32_t capacityVal)
Definition:
HeaderTable.h:30
proxygen::HeaderTable::add
virtual bool add(HPACKHeader header)
Definition:
HeaderTable.cpp:33
proxygen::HeaderTable::size_
uint32_t size_
Definition:
HeaderTable.h:191
proxygen
lib
http
codec
compress
HeaderTable.h
Generated by
1.8.11