Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> |
| 11 #include <ios> | 11 #include <ios> |
| 12 #include <iterator> | 12 #include <iterator> |
| 13 #include <list> | 13 #include <list> |
| 14 #include <memory> | 14 #include <memory> |
| 15 #include <new> | 15 #include <new> |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 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/trace_event/memory_usage_estimator.h" | |
| 24 #include "net/quic/core/quic_flags.h" | 25 #include "net/quic/core/quic_flags.h" |
| 25 #include "net/spdy/hpack/hpack_constants.h" | 26 #include "net/spdy/hpack/hpack_constants.h" |
| 26 #include "net/spdy/hpack/hpack_decoder.h" | 27 #include "net/spdy/hpack/hpack_decoder.h" |
| 27 #include "net/spdy/hpack/hpack_decoder2.h" | 28 #include "net/spdy/hpack/hpack_decoder2.h" |
| 28 #include "net/spdy/hpack/hpack_decoder3.h" | 29 #include "net/spdy/hpack/hpack_decoder3.h" |
| 29 #include "net/spdy/http2_frame_decoder_adapter.h" | 30 #include "net/spdy/http2_frame_decoder_adapter.h" |
| 30 #include "net/spdy/spdy_bitmasks.h" | 31 #include "net/spdy/spdy_bitmasks.h" |
| 31 #include "net/spdy/spdy_bug_tracker.h" | 32 #include "net/spdy/spdy_bug_tracker.h" |
| 32 #include "net/spdy/spdy_flags.h" | 33 #include "net/spdy/spdy_flags.h" |
| 33 #include "net/spdy/spdy_frame_builder.h" | 34 #include "net/spdy/spdy_frame_builder.h" |
| (...skipping 2376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2410 } else { | 2411 } else { |
| 2411 GetHpackDecoder()->SetHeaderTableDebugVisitor(std::move(visitor)); | 2412 GetHpackDecoder()->SetHeaderTableDebugVisitor(std::move(visitor)); |
| 2412 } | 2413 } |
| 2413 } | 2414 } |
| 2414 | 2415 |
| 2415 void SpdyFramer::SetEncoderHeaderTableDebugVisitor( | 2416 void SpdyFramer::SetEncoderHeaderTableDebugVisitor( |
| 2416 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor) { | 2417 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor) { |
| 2417 GetHpackEncoder()->SetHeaderTableDebugVisitor(std::move(visitor)); | 2418 GetHpackEncoder()->SetHeaderTableDebugVisitor(std::move(visitor)); |
| 2418 } | 2419 } |
| 2419 | 2420 |
| 2421 size_t SpdyFramer::EstimateMemoryUsage() const { | |
| 2422 size_t memory_estimate = | |
| 2423 current_frame_buffer_.len() + settings_scratch_.buffer.len(); | |
|
DmitrySkiba
2017/02/02 18:16:27
CharBuffer should implement EMU (where it should r
xunjieli
2017/02/03 22:25:09
Done.
| |
| 2424 if (altsvc_scratch_) | |
| 2425 memory_estimate += altsvc_scratch_->len(); | |
| 2426 memory_estimate += base::trace_event::EstimateMemoryUsage(hpack_encoder_) + | |
| 2427 base::trace_event::EstimateMemoryUsage(hpack_decoder_); | |
| 2428 return memory_estimate; | |
| 2429 } | |
| 2430 | |
| 2420 void SpdyFramer::UpdateHeaderEncoderTableSize(uint32_t value) { | 2431 void SpdyFramer::UpdateHeaderEncoderTableSize(uint32_t value) { |
| 2421 GetHpackEncoder()->ApplyHeaderTableSizeSetting(value); | 2432 GetHpackEncoder()->ApplyHeaderTableSizeSetting(value); |
| 2422 } | 2433 } |
| 2423 | 2434 |
| 2424 void SpdyFramer::UpdateHeaderDecoderTableSize(uint32_t value) { | 2435 void SpdyFramer::UpdateHeaderDecoderTableSize(uint32_t value) { |
| 2425 GetHpackDecoder()->ApplyHeaderTableSizeSetting(value); | 2436 GetHpackDecoder()->ApplyHeaderTableSizeSetting(value); |
| 2426 } | 2437 } |
| 2427 | 2438 |
| 2428 size_t SpdyFramer::header_encoder_table_size() const { | 2439 size_t SpdyFramer::header_encoder_table_size() const { |
| 2429 if (hpack_encoder_ == nullptr) { | 2440 if (hpack_encoder_ == nullptr) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2440 builder->WriteUInt32(header_block.size()); | 2451 builder->WriteUInt32(header_block.size()); |
| 2441 | 2452 |
| 2442 // Serialize each header. | 2453 // Serialize each header. |
| 2443 for (const auto& header : header_block) { | 2454 for (const auto& header : header_block) { |
| 2444 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); | 2455 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); |
| 2445 builder->WriteStringPiece32(header.second); | 2456 builder->WriteStringPiece32(header.second); |
| 2446 } | 2457 } |
| 2447 } | 2458 } |
| 2448 | 2459 |
| 2449 } // namespace net | 2460 } // namespace net |
| OLD | NEW |