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

Side by Side Diff: net/spdy/http2_frame_decoder_adapter.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 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/http2_frame_decoder_adapter.h" 5 #include "net/spdy/http2_frame_decoder_adapter.h"
6 6
7 // Logging policy: If an error in the input is detected, VLOG(n) is used so that 7 // Logging policy: If an error in the input is detected, VLOG(n) is used so that
8 // the option exists to debug the situation. Otherwise, this code mostly uses 8 // the option exists to debug the situation. Otherwise, this code mostly uses
9 // DVLOG so that the logging does not slow down production code when things are 9 // DVLOG so that the logging does not slow down production code when things are
10 // working OK. 10 // working OK.
11 11
12 #include <stddef.h> 12 #include <stddef.h>
13 13
14 #include <cstdint> 14 #include <cstdint>
15 #include <cstring> 15 #include <cstring>
16 #include <string> 16 #include <string>
17 #include <utility> 17 #include <utility>
18 18
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/optional.h" 20 #include "base/optional.h"
21 #include "base/strings/string_piece.h" 21 #include "base/strings/string_piece.h"
22 #include "base/sys_byteorder.h" 22 #include "base/sys_byteorder.h"
23 #include "base/trace_event/memory_usage_estimator.h"
23 #include "net/http2/decoder/decode_buffer.h" 24 #include "net/http2/decoder/decode_buffer.h"
24 #include "net/http2/decoder/decode_status.h" 25 #include "net/http2/decoder/decode_status.h"
25 #include "net/http2/decoder/http2_frame_decoder.h" 26 #include "net/http2/decoder/http2_frame_decoder.h"
26 #include "net/http2/decoder/http2_frame_decoder_listener.h" 27 #include "net/http2/decoder/http2_frame_decoder_listener.h"
27 #include "net/http2/http2_constants.h" 28 #include "net/http2/http2_constants.h"
28 #include "net/http2/http2_structures.h" 29 #include "net/http2/http2_structures.h"
29 #include "net/spdy/hpack/hpack_decoder_interface.h" 30 #include "net/spdy/hpack/hpack_decoder_interface.h"
30 #include "net/spdy/hpack/hpack_header_table.h" 31 #include "net/spdy/hpack/hpack_header_table.h"
31 #include "net/spdy/spdy_alt_svc_wire_format.h" 32 #include "net/spdy/spdy_alt_svc_wire_format.h"
32 #include "net/spdy/spdy_bug_tracker.h" 33 #include "net/spdy/spdy_bug_tracker.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 SpdyState state() const override { return spdy_state_; } 137 SpdyState state() const override { return spdy_state_; }
137 138
138 SpdyFramerError spdy_framer_error() const override { 139 SpdyFramerError spdy_framer_error() const override {
139 return spdy_framer_error_; 140 return spdy_framer_error_;
140 } 141 }
141 142
142 bool probable_http_response() const override { 143 bool probable_http_response() const override {
143 return latched_probable_http_response_; 144 return latched_probable_http_response_;
144 } 145 }
145 146
147 size_t EstimateMemoryUsage() const override {
148 // Skip |frame_decoder_|, |frame_header_| and |hpack_first_frame_header_| as
149 // they don't allocate.
150 return base::trace_event::EstimateMemoryUsage(alt_svc_origin_) +
151 base::trace_event::EstimateMemoryUsage(alt_svc_value_);
152 }
146 // =========================================================================== 153 // ===========================================================================
147 // Implementations of the methods declared by Http2FrameDecoderListener. 154 // Implementations of the methods declared by Http2FrameDecoderListener.
148 155
149 // Called once the common frame header has been decoded for any frame. 156 // Called once the common frame header has been decoded for any frame.
150 // This function is largely based on SpdyFramer::ValidateFrameHeader 157 // This function is largely based on SpdyFramer::ValidateFrameHeader
151 // and some parts of SpdyFramer::ProcessCommonHeader. 158 // and some parts of SpdyFramer::ProcessCommonHeader.
152 bool OnFrameHeader(const Http2FrameHeader& header) override { 159 bool OnFrameHeader(const Http2FrameHeader& header) override {
153 DVLOG(1) << "OnFrameHeader: " << header; 160 DVLOG(1) << "OnFrameHeader: " << header;
154 decoded_frame_header_ = true; 161 decoded_frame_header_ = true;
155 if (!latched_probable_http_response_) { 162 if (!latched_probable_http_response_) {
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 962
956 } // namespace 963 } // namespace
957 964
958 std::unique_ptr<SpdyFramerDecoderAdapter> CreateHttp2FrameDecoderAdapter( 965 std::unique_ptr<SpdyFramerDecoderAdapter> CreateHttp2FrameDecoderAdapter(
959 SpdyFramer* outer_framer) { 966 SpdyFramer* outer_framer) {
960 return std::unique_ptr<SpdyFramerDecoderAdapter>( 967 return std::unique_ptr<SpdyFramerDecoderAdapter>(
961 new Http2DecoderAdapter(outer_framer)); 968 new Http2DecoderAdapter(outer_framer));
962 } 969 }
963 970
964 } // namespace net 971 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698