| Index: net/spdy/hpack_encoder.cc
|
| diff --git a/net/spdy/hpack_encoder.cc b/net/spdy/hpack_encoder.cc
|
| index 81d33ad171d38aaaaee3058cb3df5593b20f230c..502b60484c35f571afcd5b667f4a8d6c44b97488 100644
|
| --- a/net/spdy/hpack_encoder.cc
|
| +++ b/net/spdy/hpack_encoder.cc
|
| @@ -31,7 +31,9 @@ const uint8 kReferencedThisEncoding = 3;
|
| HpackEncoder::HpackEncoder(const HpackHuffmanTable& table)
|
| : output_stream_(),
|
| allow_huffman_compression_(true),
|
| - huffman_table_(table) {}
|
| + huffman_table_(table),
|
| + char_counts_(NULL),
|
| + total_char_counts_(NULL) {}
|
|
|
| HpackEncoder::~HpackEncoder() {}
|
|
|
| @@ -178,6 +180,7 @@ void HpackEncoder::EmitString(StringPiece str) {
|
| output_stream_.AppendUint32(str.size());
|
| output_stream_.AppendBytes(str);
|
| }
|
| + UpdateCharacterCounts(str);
|
| }
|
|
|
| // static
|
| @@ -237,6 +240,23 @@ HpackEncoder::Representations HpackEncoder::DetermineEncodingDelta(
|
| return explicit_set;
|
| }
|
|
|
| +void HpackEncoder::SetCharCountsStorage(std::vector<size_t>* char_counts,
|
| + size_t* total_char_counts) {
|
| + CHECK_LE(256u, char_counts->size());
|
| + char_counts_ = char_counts;
|
| + total_char_counts_ = total_char_counts;
|
| +}
|
| +
|
| +void HpackEncoder::UpdateCharacterCounts(base::StringPiece str) {
|
| + if (char_counts_ == NULL || total_char_counts_ == NULL) {
|
| + return;
|
| + }
|
| + for (StringPiece::const_iterator it = str.begin(); it != str.end(); ++it) {
|
| + ++(*char_counts_)[static_cast<uint8>(*it)];
|
| + }
|
| + (*total_char_counts_) += str.size();
|
| +}
|
| +
|
| // static
|
| void HpackEncoder::CookieToCrumbs(const Representation& cookie,
|
| Representations* out) {
|
|
|