Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/spdy/hpack/hpack_encoder.h" | 5 #include "net/spdy/hpack/hpack_encoder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 return; | 125 return; |
| 126 } | 126 } |
| 127 if (size_setting < header_table_.settings_size_bound()) { | 127 if (size_setting < header_table_.settings_size_bound()) { |
| 128 min_table_size_setting_received_ = | 128 min_table_size_setting_received_ = |
| 129 std::min(size_setting, min_table_size_setting_received_); | 129 std::min(size_setting, min_table_size_setting_received_); |
| 130 } | 130 } |
| 131 header_table_.SetSettingsHeaderTableSize(size_setting); | 131 header_table_.SetSettingsHeaderTableSize(size_setting); |
| 132 should_emit_table_size_ = true; | 132 should_emit_table_size_ = true; |
| 133 } | 133 } |
| 134 | 134 |
| 135 size_t HpackEncoder::EstimateMemoryUsage() const { | |
| 136 // |huffman_table_| is a singleton. It's accounted for in spdy_session_pool.cc | |
| 137 return header_table_.size() + output_stream_.size(); | |
|
DmitrySkiba
2017/02/02 18:16:27
They should both be EMUs - header_table_.size() it
xunjieli
2017/02/03 22:25:09
Done.
| |
| 138 } | |
| 139 | |
| 135 void HpackEncoder::EncodeRepresentations(RepresentationIterator* iter, | 140 void HpackEncoder::EncodeRepresentations(RepresentationIterator* iter, |
| 136 string* output) { | 141 string* output) { |
| 137 MaybeEmitTableSize(); | 142 MaybeEmitTableSize(); |
| 138 while (iter->HasNext()) { | 143 while (iter->HasNext()) { |
| 139 const auto header = iter->Next(); | 144 const auto header = iter->Next(); |
| 140 listener_(header.first, header.second); | 145 listener_(header.first, header.second); |
| 141 if (enable_compression_) { | 146 if (enable_compression_) { |
| 142 const HpackEntry* entry = | 147 const HpackEntry* entry = |
| 143 header_table_.GetByNameAndValue(header.first, header.second); | 148 header_table_.GetByNameAndValue(header.first, header.second); |
| 144 if (entry != nullptr) { | 149 if (entry != nullptr) { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 has_next_ = encoder_->output_stream_.size() > max_encoded_bytes; | 362 has_next_ = encoder_->output_stream_.size() > max_encoded_bytes; |
| 358 encoder_->output_stream_.BoundedTakeString(max_encoded_bytes, output); | 363 encoder_->output_stream_.BoundedTakeString(max_encoded_bytes, output); |
| 359 } | 364 } |
| 360 | 365 |
| 361 std::unique_ptr<HpackEncoder::ProgressiveEncoder> HpackEncoder::EncodeHeaderSet( | 366 std::unique_ptr<HpackEncoder::ProgressiveEncoder> HpackEncoder::EncodeHeaderSet( |
| 362 const SpdyHeaderBlock& header_set) { | 367 const SpdyHeaderBlock& header_set) { |
| 363 return base::MakeUnique<Encoderator>(header_set, this); | 368 return base::MakeUnique<Encoderator>(header_set, this); |
| 364 } | 369 } |
| 365 | 370 |
| 366 } // namespace net | 371 } // namespace net |
| OLD | NEW |