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/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" | |
29 #include "net/spdy/hpack/hpack_decoder3.h" | 28 #include "net/spdy/hpack/hpack_decoder3.h" |
30 #include "net/spdy/http2_frame_decoder_adapter.h" | 29 #include "net/spdy/http2_frame_decoder_adapter.h" |
31 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" | 30 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" |
32 #include "net/spdy/spdy_bitmasks.h" | 31 #include "net/spdy/spdy_bitmasks.h" |
33 #include "net/spdy/spdy_bug_tracker.h" | 32 #include "net/spdy/spdy_bug_tracker.h" |
34 #include "net/spdy/spdy_flags.h" | 33 #include "net/spdy/spdy_flags.h" |
35 #include "net/spdy/spdy_frame_builder.h" | 34 #include "net/spdy/spdy_frame_builder.h" |
36 #include "net/spdy/spdy_frame_reader.h" | 35 #include "net/spdy/spdy_frame_reader.h" |
37 #include "net/spdy/spdy_framer_decoder_adapter.h" | 36 #include "net/spdy/spdy_framer_decoder_adapter.h" |
38 | 37 |
(...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2396 if (!compression_enabled()) { | 2395 if (!compression_enabled()) { |
2397 hpack_encoder_->DisableCompression(); | 2396 hpack_encoder_->DisableCompression(); |
2398 } | 2397 } |
2399 } | 2398 } |
2400 return hpack_encoder_.get(); | 2399 return hpack_encoder_.get(); |
2401 } | 2400 } |
2402 | 2401 |
2403 HpackDecoderInterface* SpdyFramer::GetHpackDecoder() { | 2402 HpackDecoderInterface* SpdyFramer::GetHpackDecoder() { |
2404 if (hpack_decoder_.get() == nullptr) { | 2403 if (hpack_decoder_.get() == nullptr) { |
2405 if (FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3) { | 2404 if (FLAGS_chromium_http2_flag_spdy_use_hpack_decoder3) { |
2406 SPDY_BUG_IF(FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2) | |
2407 << "Both alternate decoders are enabled."; | |
2408 hpack_decoder_.reset(new HpackDecoder3()); | 2405 hpack_decoder_.reset(new HpackDecoder3()); |
2409 } else if (FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2) { | |
2410 hpack_decoder_.reset(new HpackDecoder2()); | |
2411 } else { | 2406 } else { |
2412 hpack_decoder_.reset(new HpackDecoder()); | 2407 hpack_decoder_.reset(new HpackDecoder()); |
2413 } | 2408 } |
2414 } | 2409 } |
2415 return hpack_decoder_.get(); | 2410 return hpack_decoder_.get(); |
2416 } | 2411 } |
2417 | 2412 |
2418 void SpdyFramer::SetDecoderHeaderTableDebugVisitor( | 2413 void SpdyFramer::SetDecoderHeaderTableDebugVisitor( |
2419 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor) { | 2414 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor) { |
2420 if (decoder_adapter_ != nullptr) { | 2415 if (decoder_adapter_ != nullptr) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2461 builder->WriteUInt32(header_block.size()); | 2456 builder->WriteUInt32(header_block.size()); |
2462 | 2457 |
2463 // Serialize each header. | 2458 // Serialize each header. |
2464 for (const auto& header : header_block) { | 2459 for (const auto& header : header_block) { |
2465 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); | 2460 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); |
2466 builder->WriteStringPiece32(header.second); | 2461 builder->WriteStringPiece32(header.second); |
2467 } | 2462 } |
2468 } | 2463 } |
2469 | 2464 |
2470 } // namespace net | 2465 } // namespace net |
OLD | NEW |