| 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" | 26 #include "net/spdy/hpack/hpack_decoder.h" |
| 27 #include "net/spdy/hpack/hpack_decoder2.h" | 27 #include "net/spdy/hpack/hpack_decoder2.h" |
| 28 #include "net/spdy/http2_frame_decoder_adapter.h" |
| 28 #include "net/spdy/spdy_bitmasks.h" | 29 #include "net/spdy/spdy_bitmasks.h" |
| 29 #include "net/spdy/spdy_bug_tracker.h" | 30 #include "net/spdy/spdy_bug_tracker.h" |
| 30 #include "net/spdy/spdy_flags.h" | 31 #include "net/spdy/spdy_flags.h" |
| 31 #include "net/spdy/spdy_frame_builder.h" | 32 #include "net/spdy/spdy_frame_builder.h" |
| 32 #include "net/spdy/spdy_frame_reader.h" | 33 #include "net/spdy/spdy_frame_reader.h" |
| 33 #include "net/spdy/spdy_framer_decoder_adapter.h" | 34 #include "net/spdy/spdy_framer_decoder_adapter.h" |
| 34 #include "net/spdy/spdy_headers_block_parser.h" | 35 #include "net/spdy/spdy_headers_block_parser.h" |
| 35 | 36 |
| 36 using base::StringPiece; | 37 using base::StringPiece; |
| 37 using std::hex; | 38 using std::hex; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 61 *exclusive = (packed >> 31) != 0; | 62 *exclusive = (packed >> 31) != 0; |
| 62 // Zero out the highest-order bit to get the parent stream id. | 63 // Zero out the highest-order bit to get the parent stream id. |
| 63 *parent_stream_id = packed & 0x7fffffff; | 64 *parent_stream_id = packed & 0x7fffffff; |
| 64 } | 65 } |
| 65 | 66 |
| 66 // Creates a SpdyFramerDecoderAdapter if flags indicate that one should be | 67 // Creates a SpdyFramerDecoderAdapter if flags indicate that one should be |
| 67 // used. This code is isolated to hopefully make merging into Chromium easier. | 68 // used. This code is isolated to hopefully make merging into Chromium easier. |
| 68 std::unique_ptr<SpdyFramerDecoderAdapter> DecoderAdapterFactory( | 69 std::unique_ptr<SpdyFramerDecoderAdapter> DecoderAdapterFactory( |
| 69 SpdyFramer* outer) { | 70 SpdyFramer* outer) { |
| 70 if (FLAGS_use_nested_spdy_framer_decoder) { | 71 if (FLAGS_use_nested_spdy_framer_decoder) { |
| 72 if (FLAGS_use_http2_frame_decoder_adapter) { |
| 73 SPDY_BUG << "Two SpdyFramerDecoderAdapter are enabled!"; |
| 74 } |
| 71 DVLOG(1) << "Creating NestedSpdyFramerDecoder."; | 75 DVLOG(1) << "Creating NestedSpdyFramerDecoder."; |
| 72 return CreateNestedSpdyFramerDecoder(outer); | 76 return CreateNestedSpdyFramerDecoder(outer); |
| 73 } | 77 } |
| 78 |
| 79 if (FLAGS_use_http2_frame_decoder_adapter) { |
| 80 DVLOG(1) << "Creating Http2FrameDecoderAdapter."; |
| 81 return CreateHttp2FrameDecoderAdapter(outer); |
| 82 } |
| 83 |
| 74 return nullptr; | 84 return nullptr; |
| 75 } | 85 } |
| 76 | 86 |
| 77 // Used to indicate no flags in a HTTP2 flags field. | 87 // Used to indicate no flags in a HTTP2 flags field. |
| 78 const uint8_t kNoFlags = 0; | 88 const uint8_t kNoFlags = 0; |
| 79 | 89 |
| 80 // Wire sizes of priority payloads. | 90 // Wire sizes of priority payloads. |
| 81 const size_t kPriorityDependencyPayloadSize = 4; | 91 const size_t kPriorityDependencyPayloadSize = 4; |
| 82 const size_t kPriorityWeightPayloadSize = 1; | 92 const size_t kPriorityWeightPayloadSize = 1; |
| 83 | 93 |
| (...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2428 builder->WriteUInt32(header_block.size()); | 2438 builder->WriteUInt32(header_block.size()); |
| 2429 | 2439 |
| 2430 // Serialize each header. | 2440 // Serialize each header. |
| 2431 for (const auto& header : header_block) { | 2441 for (const auto& header : header_block) { |
| 2432 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); | 2442 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); |
| 2433 builder->WriteStringPiece32(header.second); | 2443 builder->WriteStringPiece32(header.second); |
| 2434 } | 2444 } |
| 2435 } | 2445 } |
| 2436 | 2446 |
| 2437 } // namespace net | 2447 } // namespace net |
| OLD | NEW |