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_decoder.h" | 5 #include "net/spdy/hpack/hpack_decoder.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/trace_event/memory_usage_estimator.h" | |
| 10 #include "net/spdy/hpack/hpack_constants.h" | 11 #include "net/spdy/hpack/hpack_constants.h" |
| 11 #include "net/spdy/hpack/hpack_entry.h" | 12 #include "net/spdy/hpack/hpack_entry.h" |
| 12 #include "net/spdy/spdy_flags.h" | 13 #include "net/spdy/spdy_flags.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 using base::StringPiece; | 17 using base::StringPiece; |
| 17 using std::string; | 18 using std::string; |
| 18 | 19 |
| 19 HpackDecoder::HpackDecoder() | 20 HpackDecoder::HpackDecoder() |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 void HpackDecoder::SetHeaderTableDebugVisitor( | 110 void HpackDecoder::SetHeaderTableDebugVisitor( |
| 110 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor) { | 111 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor) { |
| 111 header_table_.set_debug_visitor(std::move(visitor)); | 112 header_table_.set_debug_visitor(std::move(visitor)); |
| 112 } | 113 } |
| 113 | 114 |
| 114 void HpackDecoder::set_max_decode_buffer_size_bytes( | 115 void HpackDecoder::set_max_decode_buffer_size_bytes( |
| 115 size_t max_decode_buffer_size_bytes) { | 116 size_t max_decode_buffer_size_bytes) { |
| 116 max_decode_buffer_size_bytes_ = max_decode_buffer_size_bytes; | 117 max_decode_buffer_size_bytes_ = max_decode_buffer_size_bytes; |
| 117 } | 118 } |
| 118 | 119 |
| 120 size_t HpackDecoder::EstimateMemoryUsage() const { | |
| 121 return header_table_.size() + | |
|
DmitrySkiba
2017/02/06 18:02:34
HpackHeaderTable has EMU now, so this should be EM
xunjieli
2017/02/08 15:42:50
Done.
| |
| 122 base::trace_event::EstimateMemoryUsage(headers_block_buffer_) + | |
| 123 base::trace_event::EstimateMemoryUsage(decoded_block_) + | |
| 124 base::trace_event::EstimateMemoryUsage(key_buffer_) + | |
| 125 base::trace_event::EstimateMemoryUsage(value_buffer_); | |
| 126 } | |
| 127 | |
| 119 bool HpackDecoder::HandleHeaderRepresentation(StringPiece name, | 128 bool HpackDecoder::HandleHeaderRepresentation(StringPiece name, |
| 120 StringPiece value) { | 129 StringPiece value) { |
| 121 size_updates_allowed_ = false; | 130 size_updates_allowed_ = false; |
| 122 total_header_bytes_ += name.size() + value.size(); | 131 total_header_bytes_ += name.size() + value.size(); |
| 123 | 132 |
| 124 if (handler_ == nullptr) { | 133 if (handler_ == nullptr) { |
| 125 decoded_block_.AppendValueOrAddHeader(name, value); | 134 decoded_block_.AppendValueOrAddHeader(name, value); |
| 126 } else { | 135 } else { |
| 127 DCHECK(decoded_block_.empty()); | 136 DCHECK(decoded_block_.empty()); |
| 128 handler_->OnHeader(name, value); | 137 handler_->OnHeader(name, value); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 } else if (input_stream->MatchPrefixAndConsume( | 276 } else if (input_stream->MatchPrefixAndConsume( |
| 268 kStringLiteralIdentityEncoded)) { | 277 kStringLiteralIdentityEncoded)) { |
| 269 return input_stream->DecodeNextIdentityString(output); | 278 return input_stream->DecodeNextIdentityString(output); |
| 270 } else { | 279 } else { |
| 271 DVLOG(1) << "String literal is neither Huffman nor identity encoded!"; | 280 DVLOG(1) << "String literal is neither Huffman nor identity encoded!"; |
| 272 return false; | 281 return false; |
| 273 } | 282 } |
| 274 } | 283 } |
| 275 | 284 |
| 276 } // namespace net | 285 } // namespace net |
| OLD | NEW |