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

Side by Side Diff: net/spdy/spdy_buffer.cc

Issue 2665283003: Improve memory estimate of SpdySessionPool in net/ MemoryDumpProvider. (Closed)
Patch Set: Address Bence comments 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_buffer.h" 5 #include "net/spdy/spdy_buffer.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/trace_event/memory_usage_estimator.h"
13 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
14 #include "net/spdy/spdy_protocol.h" 15 #include "net/spdy/spdy_protocol.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 namespace { 19 namespace {
19 20
20 // Bound on largest frame any SPDY version has allowed. 21 // Bound on largest frame any SPDY version has allowed.
21 const size_t kMaxSpdyFrameSize = 0x00ffffff; 22 const size_t kMaxSpdyFrameSize = 0x00ffffff;
22 23
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 91 }
91 92
92 void SpdyBuffer::Consume(size_t consume_size) { 93 void SpdyBuffer::Consume(size_t consume_size) {
93 ConsumeHelper(consume_size, CONSUME); 94 ConsumeHelper(consume_size, CONSUME);
94 }; 95 };
95 96
96 IOBuffer* SpdyBuffer::GetIOBufferForRemainingData() { 97 IOBuffer* SpdyBuffer::GetIOBufferForRemainingData() {
97 return new SharedFrameIOBuffer(shared_frame_, offset_); 98 return new SharedFrameIOBuffer(shared_frame_, offset_);
98 } 99 }
99 100
101 size_t SpdyBuffer::EstimateMemoryUsage() const {
102 // TODO(xunjieli): Estimate |consume_callbacks_|. https://crbug.com/669108.
103 return base::trace_event::EstimateMemoryUsage(shared_frame_->data);
104 }
105
100 void SpdyBuffer::ConsumeHelper(size_t consume_size, 106 void SpdyBuffer::ConsumeHelper(size_t consume_size,
101 ConsumeSource consume_source) { 107 ConsumeSource consume_source) {
102 DCHECK_GE(consume_size, 1u); 108 DCHECK_GE(consume_size, 1u);
103 DCHECK_LE(consume_size, GetRemainingSize()); 109 DCHECK_LE(consume_size, GetRemainingSize());
104 offset_ += consume_size; 110 offset_ += consume_size;
105 for (std::vector<ConsumeCallback>::const_iterator it = 111 for (std::vector<ConsumeCallback>::const_iterator it =
106 consume_callbacks_.begin(); it != consume_callbacks_.end(); ++it) { 112 consume_callbacks_.begin(); it != consume_callbacks_.end(); ++it) {
107 it->Run(consume_size, consume_source); 113 it->Run(consume_size, consume_source);
108 } 114 }
109 }; 115 };
110 116
111 } // namespace net 117 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698