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

Side by Side Diff: net/spdy/hpack/hpack_encoder.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_encoder.h ('k') | net/spdy/hpack/hpack_huffman_table.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 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"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "net/spdy/hpack/hpack_constants.h" 12 #include "net/spdy/hpack/hpack_constants.h"
13 #include "net/spdy/hpack/hpack_header_table.h" 13 #include "net/spdy/hpack/hpack_header_table.h"
14 #include "net/spdy/hpack/hpack_huffman_table.h" 14 #include "net/spdy/hpack/hpack_huffman_table.h"
15 #include "net/spdy/hpack/hpack_output_stream.h" 15 #include "net/spdy/hpack/hpack_output_stream.h"
16 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h"
16 17
17 namespace net { 18 namespace net {
18 19
19 using base::StringPiece; 20 using base::StringPiece;
20 using std::string; 21 using std::string;
21 22
22 class HpackEncoder::RepresentationIterator { 23 class HpackEncoder::RepresentationIterator {
23 public: 24 public:
24 // |pseudo_headers| and |regular_headers| must outlive the iterator. 25 // |pseudo_headers| and |regular_headers| must outlive the iterator.
25 RepresentationIterator(const Representations& pseudo_headers, 26 RepresentationIterator(const Representations& pseudo_headers,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return; 126 return;
126 } 127 }
127 if (size_setting < header_table_.settings_size_bound()) { 128 if (size_setting < header_table_.settings_size_bound()) {
128 min_table_size_setting_received_ = 129 min_table_size_setting_received_ =
129 std::min(size_setting, min_table_size_setting_received_); 130 std::min(size_setting, min_table_size_setting_received_);
130 } 131 }
131 header_table_.SetSettingsHeaderTableSize(size_setting); 132 header_table_.SetSettingsHeaderTableSize(size_setting);
132 should_emit_table_size_ = true; 133 should_emit_table_size_ = true;
133 } 134 }
134 135
136 size_t HpackEncoder::EstimateMemoryUsage() const {
137 // |huffman_table_| is a singleton. It's accounted for in spdy_session_pool.cc
138 return SpdyEstimateMemoryUsage(header_table_) +
139 SpdyEstimateMemoryUsage(output_stream_);
140 }
141
135 void HpackEncoder::EncodeRepresentations(RepresentationIterator* iter, 142 void HpackEncoder::EncodeRepresentations(RepresentationIterator* iter,
136 string* output) { 143 string* output) {
137 MaybeEmitTableSize(); 144 MaybeEmitTableSize();
138 while (iter->HasNext()) { 145 while (iter->HasNext()) {
139 const auto header = iter->Next(); 146 const auto header = iter->Next();
140 listener_(header.first, header.second); 147 listener_(header.first, header.second);
141 if (enable_compression_) { 148 if (enable_compression_) {
142 const HpackEntry* entry = 149 const HpackEntry* entry =
143 header_table_.GetByNameAndValue(header.first, header.second); 150 header_table_.GetByNameAndValue(header.first, header.second);
144 if (entry != nullptr) { 151 if (entry != nullptr) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 has_next_ = encoder_->output_stream_.size() > max_encoded_bytes; 364 has_next_ = encoder_->output_stream_.size() > max_encoded_bytes;
358 encoder_->output_stream_.BoundedTakeString(max_encoded_bytes, output); 365 encoder_->output_stream_.BoundedTakeString(max_encoded_bytes, output);
359 } 366 }
360 367
361 std::unique_ptr<HpackEncoder::ProgressiveEncoder> HpackEncoder::EncodeHeaderSet( 368 std::unique_ptr<HpackEncoder::ProgressiveEncoder> HpackEncoder::EncodeHeaderSet(
362 const SpdyHeaderBlock& header_set) { 369 const SpdyHeaderBlock& header_set) {
363 return base::MakeUnique<Encoderator>(header_set, this); 370 return base::MakeUnique<Encoderator>(header_set, this);
364 } 371 }
365 372
366 } // namespace net 373 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_encoder.h ('k') | net/spdy/hpack/hpack_huffman_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698