proxygen
|
#include <HeaderTable.h>
Public Types | |
using | names_map = std::unordered_map< HPACKHeaderName, std::list< uint32_t >> |
Public Member Functions | |
HeaderTable (uint32_t capacityVal) | |
virtual | ~HeaderTable () |
HeaderTable (const HeaderTable &)=delete | |
HeaderTable & | operator= (const HeaderTable &)=delete |
virtual bool | add (HPACKHeader header) |
uint32_t | getIndex (const HPACKHeader &header) const |
const HPACKHeader & | getHeader (uint32_t index) const |
bool | isValid (uint32_t index) const |
bool | hasName (const HPACKHeaderName &headerName) |
const names_map & | names () const |
uint32_t | nameIndex (const HPACKHeaderName &headerName) const |
uint32_t | capacity () const |
uint32_t | getMaxTableLength (uint32_t capacityVal) |
virtual bool | setCapacity (uint32_t capacity) |
uint32_t | size () const |
uint32_t | bytes () const |
size_t | length () const |
bool | operator== (const HeaderTable &other) const |
Static Public Member Functions | |
static uint32_t | toExternal (uint32_t head, uint32_t length, uint32_t internalIndex) |
static uint32_t | toInternal (uint32_t head, uint32_t length, uint32_t externalIndex) |
Protected Member Functions | |
void | init (uint32_t capacityVal) |
virtual void | increaseTableLengthTo (uint32_t newLength) |
virtual void | resizeTable (uint32_t newLength) |
virtual void | updateResizedTable (uint32_t oldTail, uint32_t oldLength, uint32_t newLength) |
virtual uint32_t | removeLast () |
void | reset () |
virtual uint32_t | evict (uint32_t needed, uint32_t desiredCapacity) |
uint32_t | next (uint32_t i) const |
uint32_t | tail () const |
uint32_t | toExternal (uint32_t internalIndex) const |
uint32_t | toInternal (uint32_t externalIndex) const |
Protected Attributes | |
uint32_t | capacity_ {0} |
uint32_t | bytes_ {0} |
std::vector< HPACKHeader > | table_ |
uint32_t | size_ {0} |
uint32_t | head_ {0} |
names_map | names_ |
Private Member Functions | |
uint32_t | getIndexImpl (const HPACKHeaderName &header, const folly::fbstring &value, bool nameOnly) const |
Data structure for maintaining indexed headers, based on a fixed-length ring with FIFO semantics. Externally it acts as an array.
Definition at line 26 of file HeaderTable.h.
using proxygen::HeaderTable::names_map = std::unordered_map<HPACKHeaderName, std::list<uint32_t>> |
Definition at line 28 of file HeaderTable.h.
|
inlineexplicit |
|
inlinevirtual |
Definition at line 34 of file HeaderTable.h.
References add(), getHeader(), getIndex(), hasName(), HeaderTable(), isValid(), operator=(), and uint32_t.
|
delete |
|
virtual |
Add the header entry at the beginning of the table (index=1)
Reimplemented in proxygen::QPACKHeaderTable.
Definition at line 33 of file HeaderTable.cpp.
References proxygen::HPACKHeader::bytes(), bytes_, capacity_, folly::chrono::ceil(), evict(), getMaxTableLength(), head_, increaseTableLengthTo(), length(), min, folly::gen::move, proxygen::HPACKHeader::name, names_, next(), reset(), size_, table_, and uint32_t.
Referenced by proxygen::QPACKHeaderTable::add(), proxygen::HPACKDecoder::decodeLiteralHeader(), proxygen::HPACKEncoder::encodeAsLiteral(), proxygen::HeaderTableTests::resizeAndFillTable(), proxygen::HPACKContext::seedHeaderTable(), proxygen::StaticHeaderTable::StaticHeaderTable(), proxygen::TEST_F(), and ~HeaderTable().
|
inline |
Definition at line 112 of file HeaderTable.h.
References bytes_.
Referenced by proxygen::QPACKHeaderTable::add(), proxygen::QPACKContext::getBytesStored(), proxygen::HPACKContext::getBytesStored(), proxygen::operator<<(), operator==(), proxygen::HeaderTableTests::resizeAndFillTable(), proxygen::TEST_F(), and TEST_P().
|
inline |
Table capacity, or maximum number of bytes we can hold.
Definition at line 86 of file HeaderTable.h.
References capacity_, getMaxTableLength(), setCapacity(), and uint32_t.
Referenced by proxygen::HPACKEncoder::encode(), proxygen::QPACKEncoder::encode(), proxygen::HPACKEncoder::encodeAsLiteral(), proxygen::QPACKContext::getTableSize(), proxygen::HPACKContext::getTableSize(), proxygen::QPACKHeaderTable::isDraining(), proxygen::HPACKEncoderBase::setHeaderTableSize(), and proxygen::QPACKEncoder::shouldIndex().
|
protectedvirtual |
Evict entries to make space for the needed amount of bytes.
Reimplemented in proxygen::QPACKHeaderTable.
Definition at line 196 of file HeaderTable.cpp.
References bytes_, removeLast(), size_, and uint32_t.
Referenced by add(), proxygen::QPACKHeaderTable::evict(), length(), and setCapacity().
const HPACKHeader & proxygen::HeaderTable::getHeader | ( | uint32_t | index | ) | const |
Get the table entry at the given external index.
Definition at line 93 of file HeaderTable.cpp.
References isValid(), table_, and toInternal().
Referenced by proxygen::QPACKContext::getHeader(), proxygen::HPACKContext::getHeader(), proxygen::operator<<(), proxygen::TEST_F(), and ~HeaderTable().
uint32_t proxygen::HeaderTable::getIndex | ( | const HPACKHeader & | header | ) | const |
Get the index of the given header, if found.
Definition at line 63 of file HeaderTable.cpp.
References getIndexImpl(), proxygen::HPACKHeader::name, and proxygen::HPACKHeader::value.
Referenced by proxygen::QPACKEncoder::encodeHeaderQ(), proxygen::HPACKContext::getIndex(), proxygen::TEST_F(), and ~HeaderTable().
|
private |
Definition at line 67 of file HeaderTable.cpp.
References i, names_, table_, and toExternal().
Referenced by getIndex(), and nameIndex().
Returns the maximum table length required to support HPACK headers given the specified capacity bytes
Definition at line 98 of file HeaderTable.cpp.
Referenced by add(), capacity(), init(), setCapacity(), and proxygen::TEST_F().
bool proxygen::HeaderTable::hasName | ( | const HPACKHeaderName & | headerName | ) |
Definition at line 84 of file HeaderTable.cpp.
References names_.
Referenced by proxygen::TEST_F(), and ~HeaderTable().
|
protectedvirtual |
Reimplemented in proxygen::QPACKHeaderTable.
Definition at line 159 of file HeaderTable.cpp.
References head_, length(), names_, resizeTable(), size_, tail(), uint32_t, and updateResizedTable().
Referenced by add(), proxygen::QPACKHeaderTable::increaseTableLengthTo(), length(), and setCapacity().
|
protected |
Initialize with a given capacity.
Definition at line 20 of file HeaderTable.cpp.
References bytes_, capacity_, getMaxTableLength(), head_, i, names_, size_, table_, and uint32_t.
Referenced by HeaderTable(), length(), and proxygen::StaticHeaderTable::StaticHeaderTable().
bool proxygen::HeaderTable::isValid | ( | uint32_t | index | ) | const |
Checks if an external index is valid.
Definition at line 204 of file HeaderTable.cpp.
References proxygen::ERROR, and size_.
Referenced by getHeader(), proxygen::HPACKDecoder::isValid(), proxygen::QPACKDecoder::isValid(), proxygen::QPACKHeaderTable::isValid(), and ~HeaderTable().
|
inline |
Definition at line 119 of file HeaderTable.h.
References evict(), i, increaseTableLengthTo(), init(), next(), operator==(), removeLast(), reset(), resizeTable(), table_, tail(), toExternal(), toInternal(), uint32_t, and updateResizedTable().
Referenced by add(), increaseTableLengthTo(), next(), setCapacity(), tail(), proxygen::TEST_F(), toExternal(), and toInternal().
uint32_t proxygen::HeaderTable::nameIndex | ( | const HPACKHeaderName & | headerName | ) | const |
Get any index of a header that has the given name. From all the headers with the given name we pick the last one added to the header table, but the way we pick the header can be arbitrary.
Definition at line 88 of file HeaderTable.cpp.
References getIndexImpl(), and value.
Referenced by proxygen::QPACKEncoder::getNameIndexQ(), proxygen::HPACKContext::nameIndex(), names(), and proxygen::TEST_F().
|
inline |
Definition at line 72 of file HeaderTable.h.
References nameIndex(), names_, and uint32_t.
Referenced by proxygen::TEST_F().
Move the index to the right.
Definition at line 213 of file HeaderTable.cpp.
References length().
Referenced by add(), proxygen::QPACKHeaderTable::canEvict(), and length().
|
delete |
Referenced by ~HeaderTable().
bool proxygen::HeaderTable::operator== | ( | const HeaderTable & | other | ) | const |
Definition at line 244 of file HeaderTable.cpp.
References bytes(), and size().
Referenced by length().
|
protectedvirtual |
Removes one header entry from the beginning of the header table.
Returns the size of the removed header
Reimplemented in proxygen::QPACKHeaderTable.
Definition at line 105 of file HeaderTable.cpp.
References bytes_, name, names_, size_, folly::pushmi::detail::t, table_, tail(), and uint32_t.
Referenced by evict(), length(), and proxygen::QPACKHeaderTable::removeLast().
|
protected |
|
protectedvirtual |
Reimplemented in proxygen::QPACKHeaderTable.
Definition at line 186 of file HeaderTable.cpp.
References table_.
Referenced by increaseTableLengthTo(), length(), and proxygen::QPACKHeaderTable::resizeTable().
|
virtual |
Sets the current capacity of the header table, and evicts entries if needed. Returns false if eviction failed.
Reimplemented in proxygen::QPACKHeaderTable.
Definition at line 136 of file HeaderTable.cpp.
References bytes_, capacity_, evict(), getMaxTableLength(), increaseTableLengthTo(), length(), and uint32_t.
Referenced by capacity(), proxygen::HPACKDecoderBase::handleTableSizeUpdate(), proxygen::HeaderTableTests::resizeTable(), proxygen::QPACKHeaderTable::setCapacity(), proxygen::HPACKEncoderBase::setHeaderTableSize(), and proxygen::TEST_F().
|
inline |
Definition at line 105 of file HeaderTable.h.
References size_.
Referenced by proxygen::QPACKHeaderTable::canEvict(), proxygen::HPACKContext::dynamicToGlobalIndex(), proxygen::QPACKContext::getHeadersStored(), proxygen::HPACKContext::getHeadersStored(), proxygen::HPACKContext::globalToDynamicIndex(), proxygen::HPACKContext::isStatic(), proxygen::operator<<(), operator==(), proxygen::QPACKHeaderTable::removeLast(), proxygen::HeaderTableTests::resizeAndFillTable(), proxygen::HeaderTableTests::resizeTable(), proxygen::StaticHeaderTable::StaticHeaderTable(), TEST_F(), proxygen::TEST_F(), and TEST_P().
|
protected |
Get the index of the tail element of the table.
Definition at line 217 of file HeaderTable.cpp.
References head_, length(), and size_.
Referenced by proxygen::QPACKHeaderTable::canEvict(), increaseTableLengthTo(), proxygen::QPACKHeaderTable::increaseTableLengthTo(), length(), removeLast(), and proxygen::QPACKHeaderTable::removeLast().
|
static |
Static versions of the methods that translate indices.
Definition at line 228 of file HeaderTable.cpp.
Referenced by proxygen::QPACKHeaderTable::getIndexImpl(), getIndexImpl(), proxygen::QPACKHeaderTable::internalToAbsolute(), length(), and toExternal().
Translate internal index to external one, including a static version.
Definition at line 224 of file HeaderTable.cpp.
References head_, length(), and toExternal().
|
static |
Definition at line 237 of file HeaderTable.cpp.
References length().
Referenced by getHeader(), length(), toInternal(), and proxygen::QPACKHeaderTable::toInternal().
Translate external index to internal one.
Definition at line 233 of file HeaderTable.cpp.
References head_, length(), and toInternal().
|
protectedvirtual |
Reimplemented in proxygen::QPACKHeaderTable.
Definition at line 190 of file HeaderTable.cpp.
References table_.
Referenced by increaseTableLengthTo(), length(), and proxygen::QPACKHeaderTable::updateResizedTable().
|
protected |
Definition at line 188 of file HeaderTable.h.
Referenced by add(), proxygen::QPACKHeaderTable::add(), bytes(), proxygen::QPACKHeaderTable::canIndex(), evict(), proxygen::QPACKHeaderTable::evict(), init(), removeLast(), reset(), and setCapacity().
|
protected |
Definition at line 187 of file HeaderTable.h.
Referenced by add(), proxygen::QPACKHeaderTable::add(), proxygen::QPACKHeaderTable::canEvict(), proxygen::QPACKHeaderTable::canIndex(), capacity(), init(), and setCapacity().
|
protected |
Definition at line 192 of file HeaderTable.h.
Referenced by add(), proxygen::QPACKHeaderTable::add(), increaseTableLengthTo(), proxygen::QPACKHeaderTable::increaseTableLengthTo(), init(), tail(), toExternal(), and toInternal().
|
protected |
Definition at line 194 of file HeaderTable.h.
Referenced by add(), proxygen::QPACKHeaderTable::getIndexImpl(), getIndexImpl(), hasName(), increaseTableLengthTo(), init(), names(), removeLast(), and reset().
|
protected |
Definition at line 191 of file HeaderTable.h.
Referenced by add(), proxygen::QPACKHeaderTable::canEvict(), evict(), increaseTableLengthTo(), proxygen::QPACKHeaderTable::increaseTableLengthTo(), init(), isValid(), removeLast(), reset(), size(), and tail().
|
protected |
Definition at line 189 of file HeaderTable.h.
Referenced by add(), proxygen::QPACKHeaderTable::add(), proxygen::QPACKHeaderTable::canEvict(), getHeader(), proxygen::QPACKHeaderTable::getHeader(), proxygen::QPACKHeaderTable::getIndexImpl(), getIndexImpl(), init(), length(), proxygen::QPACKHeaderTable::QPACKHeaderTable(), removeLast(), resizeTable(), and updateResizedTable().