Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: net/spdy/hpack/hpack_decoder2.cc

Issue 2665283003: Improve memory estimate of SpdySessionPool in net/ MemoryDumpProvider. (Closed)
Patch Set: rebased Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/hpack/hpack_decoder2.h ('k') | net/spdy/hpack/hpack_decoder3.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_decoder2.h" 5 #include "net/spdy/hpack/hpack_decoder2.h"
6 6
7 #include <list> 7 #include <list>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_piece.h" 11 #include "base/strings/string_piece.h"
12 #include "net/http2/decoder/decode_buffer.h" 12 #include "net/http2/decoder/decode_buffer.h"
13 #include "net/http2/decoder/decode_status.h" 13 #include "net/http2/decoder/decode_status.h"
14 #include "net/spdy/hpack/hpack_entry.h" 14 #include "net/spdy/hpack/hpack_entry.h"
15 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h"
15 16
16 using base::StringPiece; 17 using base::StringPiece;
17 18
18 namespace net { 19 namespace net {
19 20
20 HpackDecoder2::HpackDecoder2() : hpack_block_decoder_(this) { 21 HpackDecoder2::HpackDecoder2() : hpack_block_decoder_(this) {
21 Reset(); 22 Reset();
22 } 23 }
23 24
24 HpackDecoder2::~HpackDecoder2() {} 25 HpackDecoder2::~HpackDecoder2() {}
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 DVLOG(2) << "HpackDecoder2::SetHeaderTableDebugVisitor"; 153 DVLOG(2) << "HpackDecoder2::SetHeaderTableDebugVisitor";
153 header_table_.set_debug_visitor(std::move(visitor)); 154 header_table_.set_debug_visitor(std::move(visitor));
154 } 155 }
155 156
156 void HpackDecoder2::set_max_decode_buffer_size_bytes( 157 void HpackDecoder2::set_max_decode_buffer_size_bytes(
157 size_t max_decode_buffer_size_bytes) { 158 size_t max_decode_buffer_size_bytes) {
158 DVLOG(2) << "HpackDecoder2::set_max_decode_buffer_size_bytes"; 159 DVLOG(2) << "HpackDecoder2::set_max_decode_buffer_size_bytes";
159 max_decode_buffer_size_bytes_ = max_decode_buffer_size_bytes; 160 max_decode_buffer_size_bytes_ = max_decode_buffer_size_bytes;
160 } 161 }
161 162
163 size_t HpackDecoder2::EstimateMemoryUsage() const {
164 return SpdyEstimateMemoryUsage(header_table_) +
165 SpdyEstimateMemoryUsage(decoded_block_) +
166 SpdyEstimateMemoryUsage(name_) + SpdyEstimateMemoryUsage(value_);
167 }
168
162 void HpackDecoder2::OnIndexedHeader(size_t index) { 169 void HpackDecoder2::OnIndexedHeader(size_t index) {
163 DVLOG(2) << "HpackDecoder2::OnIndexedHeader: index=" << index; 170 DVLOG(2) << "HpackDecoder2::OnIndexedHeader: index=" << index;
164 DCHECK(!error_detected_); 171 DCHECK(!error_detected_);
165 const HpackEntry* entry = header_table_.GetByIndex(index); 172 const HpackEntry* entry = header_table_.GetByIndex(index);
166 if (entry == nullptr) { 173 if (entry == nullptr) {
167 SetErrorDetected(); 174 SetErrorDetected();
168 return; 175 return;
169 } 176 }
170 HandleHeaderRepresentation(entry->name(), entry->value()); 177 HandleHeaderRepresentation(entry->name(), entry->value());
171 } 178 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 decoded_block_.AppendValueOrAddHeader(name, value); 328 decoded_block_.AppendValueOrAddHeader(name, value);
322 } else { 329 } else {
323 DVLOG(3) << "HpackDecoder2::HandleHeaderRepresentation " 330 DVLOG(3) << "HpackDecoder2::HandleHeaderRepresentation "
324 << "passing to handler"; 331 << "passing to handler";
325 DCHECK(decoded_block_.empty()); 332 DCHECK(decoded_block_.empty());
326 handler_->OnHeader(name, value); 333 handler_->OnHeader(name, value);
327 } 334 }
328 } 335 }
329 336
330 } // namespace net 337 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_decoder2.h ('k') | net/spdy/hpack/hpack_decoder3.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698