diff options
Diffstat (limited to 'net/spdy/hpack_huffman_table.cc')
-rw-r--r-- | net/spdy/hpack_huffman_table.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/net/spdy/hpack_huffman_table.cc b/net/spdy/hpack_huffman_table.cc index 02910eb..9e8f6a1 100644 --- a/net/spdy/hpack_huffman_table.cc +++ b/net/spdy/hpack_huffman_table.cc @@ -248,6 +248,20 @@ void HpackHuffmanTable::EncodeString(StringPiece in, } } +size_t HpackHuffmanTable::EncodedSize(StringPiece in) const { + size_t bit_count = 0; + for (size_t i = 0; i != in.size(); i++) { + uint16 symbol_id = static_cast<uint8>(in[i]); + CHECK_GT(code_by_id_.size(), symbol_id); + + bit_count += length_by_id_[symbol_id]; + } + if (bit_count % 8 != 0) { + bit_count += 8 - bit_count % 8; + } + return bit_count / 8; +} + bool HpackHuffmanTable::DecodeString(HpackInputStream* in, size_t out_capacity, string* out) const { |