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

Side by Side Diff: net/spdy/spdy_framer.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/spdy_framer.h ('k') | net/spdy/spdy_framer_decoder_adapter.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/spdy_framer.h" 5 #include "net/spdy/spdy_framer.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cctype> 10 #include <cctype>
(...skipping 10 matching lines...) Expand all
21 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
22 #include "base/metrics/histogram_macros.h" 22 #include "base/metrics/histogram_macros.h"
23 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "net/quic/core/quic_flags.h" 25 #include "net/quic/core/quic_flags.h"
26 #include "net/spdy/hpack/hpack_constants.h" 26 #include "net/spdy/hpack/hpack_constants.h"
27 #include "net/spdy/hpack/hpack_decoder.h" 27 #include "net/spdy/hpack/hpack_decoder.h"
28 #include "net/spdy/hpack/hpack_decoder2.h" 28 #include "net/spdy/hpack/hpack_decoder2.h"
29 #include "net/spdy/hpack/hpack_decoder3.h" 29 #include "net/spdy/hpack/hpack_decoder3.h"
30 #include "net/spdy/http2_frame_decoder_adapter.h" 30 #include "net/spdy/http2_frame_decoder_adapter.h"
31 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h"
31 #include "net/spdy/spdy_bitmasks.h" 32 #include "net/spdy/spdy_bitmasks.h"
32 #include "net/spdy/spdy_bug_tracker.h" 33 #include "net/spdy/spdy_bug_tracker.h"
33 #include "net/spdy/spdy_flags.h" 34 #include "net/spdy/spdy_flags.h"
34 #include "net/spdy/spdy_frame_builder.h" 35 #include "net/spdy/spdy_frame_builder.h"
35 #include "net/spdy/spdy_frame_reader.h" 36 #include "net/spdy/spdy_frame_reader.h"
36 #include "net/spdy/spdy_framer_decoder_adapter.h" 37 #include "net/spdy/spdy_framer_decoder_adapter.h"
37 38
38 using base::StringPiece; 39 using base::StringPiece;
39 using std::hex; 40 using std::hex;
40 using std::string; 41 using std::string;
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 void SpdyFramer::CharBuffer::CopyFrom(const char* data, size_t size) { 557 void SpdyFramer::CharBuffer::CopyFrom(const char* data, size_t size) {
557 DCHECK_GE(capacity_, len_ + size); 558 DCHECK_GE(capacity_, len_ + size);
558 memcpy(buffer_.get() + len_, data, size); 559 memcpy(buffer_.get() + len_, data, size);
559 len_ += size; 560 len_ += size;
560 } 561 }
561 562
562 void SpdyFramer::CharBuffer::Rewind() { 563 void SpdyFramer::CharBuffer::Rewind() {
563 len_ = 0; 564 len_ = 0;
564 } 565 }
565 566
567 size_t SpdyFramer::CharBuffer::EstimateMemoryUsage() const {
568 return capacity_;
569 }
570
566 SpdyFramer::SpdySettingsScratch::SpdySettingsScratch() 571 SpdyFramer::SpdySettingsScratch::SpdySettingsScratch()
567 : buffer(8), last_setting_id(-1) {} 572 : buffer(8), last_setting_id(-1) {}
568 573
569 void SpdyFramer::SpdySettingsScratch::Reset() { 574 void SpdyFramer::SpdySettingsScratch::Reset() {
570 buffer.Rewind(); 575 buffer.Rewind();
571 last_setting_id = -1; 576 last_setting_id = -1;
572 } 577 }
573 578
579 size_t SpdyFramer::SpdySettingsScratch::EstimateMemoryUsage() const {
580 return SpdyEstimateMemoryUsage(buffer);
581 }
582
574 SpdyFrameType SpdyFramer::ValidateFrameHeader(bool is_control_frame, 583 SpdyFrameType SpdyFramer::ValidateFrameHeader(bool is_control_frame,
575 uint8_t frame_type_field, 584 uint8_t frame_type_field,
576 size_t payload_length_field) { 585 size_t payload_length_field) {
577 if (!IsDefinedFrameType(frame_type_field)) { 586 if (!IsDefinedFrameType(frame_type_field)) {
578 // We ignore unknown frame types for extensibility, as long as 587 // We ignore unknown frame types for extensibility, as long as
579 // the rest of the control frame header is valid. 588 // the rest of the control frame header is valid.
580 // We rely on the visitor to check validity of current_frame_stream_id_. 589 // We rely on the visitor to check validity of current_frame_stream_id_.
581 bool valid_stream = 590 bool valid_stream =
582 visitor_->OnUnknownFrame(current_frame_stream_id_, frame_type_field); 591 visitor_->OnUnknownFrame(current_frame_stream_id_, frame_type_field);
583 if (expect_continuation_) { 592 if (expect_continuation_) {
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 } else { 2354 } else {
2346 GetHpackDecoder()->SetHeaderTableDebugVisitor(std::move(visitor)); 2355 GetHpackDecoder()->SetHeaderTableDebugVisitor(std::move(visitor));
2347 } 2356 }
2348 } 2357 }
2349 2358
2350 void SpdyFramer::SetEncoderHeaderTableDebugVisitor( 2359 void SpdyFramer::SetEncoderHeaderTableDebugVisitor(
2351 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor) { 2360 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor) {
2352 GetHpackEncoder()->SetHeaderTableDebugVisitor(std::move(visitor)); 2361 GetHpackEncoder()->SetHeaderTableDebugVisitor(std::move(visitor));
2353 } 2362 }
2354 2363
2364 size_t SpdyFramer::EstimateMemoryUsage() const {
2365 return SpdyEstimateMemoryUsage(current_frame_buffer_) +
2366 SpdyEstimateMemoryUsage(settings_scratch_) +
2367 SpdyEstimateMemoryUsage(altsvc_scratch_) +
2368 SpdyEstimateMemoryUsage(hpack_encoder_) +
2369 SpdyEstimateMemoryUsage(hpack_decoder_) +
2370 SpdyEstimateMemoryUsage(decoder_adapter_);
2371 }
2372
2355 void SpdyFramer::UpdateHeaderEncoderTableSize(uint32_t value) { 2373 void SpdyFramer::UpdateHeaderEncoderTableSize(uint32_t value) {
2356 GetHpackEncoder()->ApplyHeaderTableSizeSetting(value); 2374 GetHpackEncoder()->ApplyHeaderTableSizeSetting(value);
2357 } 2375 }
2358 2376
2359 void SpdyFramer::UpdateHeaderDecoderTableSize(uint32_t value) { 2377 void SpdyFramer::UpdateHeaderDecoderTableSize(uint32_t value) {
2360 GetHpackDecoder()->ApplyHeaderTableSizeSetting(value); 2378 GetHpackDecoder()->ApplyHeaderTableSizeSetting(value);
2361 } 2379 }
2362 2380
2363 size_t SpdyFramer::header_encoder_table_size() const { 2381 size_t SpdyFramer::header_encoder_table_size() const {
2364 if (hpack_encoder_ == nullptr) { 2382 if (hpack_encoder_ == nullptr) {
(...skipping 10 matching lines...) Expand all
2375 builder->WriteUInt32(header_block.size()); 2393 builder->WriteUInt32(header_block.size());
2376 2394
2377 // Serialize each header. 2395 // Serialize each header.
2378 for (const auto& header : header_block) { 2396 for (const auto& header : header_block) {
2379 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); 2397 builder->WriteStringPiece32(base::ToLowerASCII(header.first));
2380 builder->WriteStringPiece32(header.second); 2398 builder->WriteStringPiece32(header.second);
2381 } 2399 }
2382 } 2400 }
2383 2401
2384 } // namespace net 2402 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | net/spdy/spdy_framer_decoder_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698