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 "net/quic/core/quic_flags.h" | 24 #include "net/quic/core/quic_flags.h" |
25 #include "net/spdy/hpack/hpack_constants.h" | 25 #include "net/spdy/hpack/hpack_constants.h" |
| 26 #include "net/spdy/hpack/hpack_decoder.h" |
| 27 #include "net/spdy/hpack/hpack_decoder2.h" |
26 #include "net/spdy/spdy_bitmasks.h" | 28 #include "net/spdy/spdy_bitmasks.h" |
27 #include "net/spdy/spdy_bug_tracker.h" | 29 #include "net/spdy/spdy_bug_tracker.h" |
28 #include "net/spdy/spdy_flags.h" | 30 #include "net/spdy/spdy_flags.h" |
29 #include "net/spdy/spdy_frame_builder.h" | 31 #include "net/spdy/spdy_frame_builder.h" |
30 #include "net/spdy/spdy_frame_reader.h" | 32 #include "net/spdy/spdy_frame_reader.h" |
31 #include "net/spdy/spdy_framer_decoder_adapter.h" | 33 #include "net/spdy/spdy_framer_decoder_adapter.h" |
32 #include "net/spdy/spdy_headers_block_parser.h" | 34 #include "net/spdy/spdy_headers_block_parser.h" |
33 | 35 |
34 using base::StringPiece; | 36 using base::StringPiece; |
35 using std::hex; | 37 using std::hex; |
(...skipping 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2352 | 2354 |
2353 HpackEncoder* SpdyFramer::GetHpackEncoder() { | 2355 HpackEncoder* SpdyFramer::GetHpackEncoder() { |
2354 if (hpack_encoder_.get() == nullptr) { | 2356 if (hpack_encoder_.get() == nullptr) { |
2355 hpack_encoder_.reset(new HpackEncoder(ObtainHpackHuffmanTable())); | 2357 hpack_encoder_.reset(new HpackEncoder(ObtainHpackHuffmanTable())); |
2356 } | 2358 } |
2357 return hpack_encoder_.get(); | 2359 return hpack_encoder_.get(); |
2358 } | 2360 } |
2359 | 2361 |
2360 HpackDecoderInterface* SpdyFramer::GetHpackDecoder() { | 2362 HpackDecoderInterface* SpdyFramer::GetHpackDecoder() { |
2361 if (hpack_decoder_.get() == nullptr) { | 2363 if (hpack_decoder_.get() == nullptr) { |
2362 hpack_decoder_.reset(new HpackDecoder()); | 2364 if (FLAGS_chromium_http2_flag_spdy_use_hpack_decoder2) { |
| 2365 hpack_decoder_.reset(new HpackDecoder2()); |
| 2366 } else { |
| 2367 hpack_decoder_.reset(new HpackDecoder()); |
| 2368 } |
2363 } | 2369 } |
2364 return hpack_decoder_.get(); | 2370 return hpack_decoder_.get(); |
2365 } | 2371 } |
2366 | 2372 |
2367 bool SpdyFramer::IncrementallyDeliverControlFrameHeaderData( | 2373 bool SpdyFramer::IncrementallyDeliverControlFrameHeaderData( |
2368 SpdyStreamId stream_id, const char* data, size_t len) { | 2374 SpdyStreamId stream_id, const char* data, size_t len) { |
2369 bool read_successfully = true; | 2375 bool read_successfully = true; |
2370 while (read_successfully && len > 0) { | 2376 while (read_successfully && len > 0) { |
2371 size_t bytes_to_deliver = std::min(len, kHeaderDataChunkMaxSize); | 2377 size_t bytes_to_deliver = std::min(len, kHeaderDataChunkMaxSize); |
2372 read_successfully = header_parser_->HandleControlFrameHeadersData( | 2378 read_successfully = header_parser_->HandleControlFrameHeadersData( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2422 builder->WriteUInt32(header_block.size()); | 2428 builder->WriteUInt32(header_block.size()); |
2423 | 2429 |
2424 // Serialize each header. | 2430 // Serialize each header. |
2425 for (const auto& header : header_block) { | 2431 for (const auto& header : header_block) { |
2426 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); | 2432 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); |
2427 builder->WriteStringPiece32(header.second); | 2433 builder->WriteStringPiece32(header.second); |
2428 } | 2434 } |
2429 } | 2435 } |
2430 | 2436 |
2431 } // namespace net | 2437 } // namespace net |
OLD | NEW |