| Index: net/spdy/hpack_encoder.cc
|
| diff --git a/net/spdy/hpack_encoder.cc b/net/spdy/hpack_encoder.cc
|
| index 469042687718e25f7a23e689e1fb900688123818..d037fa837557199c1ee188da417042de8af65a4c 100644
|
| --- a/net/spdy/hpack_encoder.cc
|
| +++ b/net/spdy/hpack_encoder.cc
|
| @@ -13,7 +13,10 @@ using base::StringPiece;
|
| using std::string;
|
|
|
| HpackEncoder::HpackEncoder()
|
| - : max_string_literal_size_(kDefaultMaxStringLiteralSize) {}
|
| + : max_string_literal_size_(kDefaultMaxStringLiteralSize),
|
| + char_counts_(NULL),
|
| + total_char_counts_(NULL) {
|
| +}
|
|
|
| HpackEncoder::~HpackEncoder() {}
|
|
|
| @@ -38,11 +41,20 @@ bool HpackEncoder::EncodeHeaderSet(const std::map<string, string>& header_set,
|
| it->first, it->second)) {
|
| return false;
|
| }
|
| + UpdateCharacterCounts(it->first);
|
| + UpdateCharacterCounts(it->second);
|
| }
|
| output_stream.TakeString(output);
|
| return true;
|
| }
|
|
|
| +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::CookieToCrumbs(StringPiece cookie,
|
| std::vector<StringPiece>* out) {
|
| out->clear();
|
| @@ -63,4 +75,14 @@ void HpackEncoder::CookieToCrumbs(StringPiece cookie,
|
| }
|
| }
|
|
|
| +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();
|
| +}
|
| +
|
| } // namespace net
|
|
|