OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef NET_SPDY_HPACK_DECODER_H_ | 5 #ifndef NET_SPDY_HPACK_DECODER_H_ |
6 #define NET_SPDY_HPACK_DECODER_H_ | 6 #define NET_SPDY_HPACK_DECODER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
18 #include "net/spdy/hpack/hpack_header_table.h" | 18 #include "net/spdy/hpack/hpack_header_table.h" |
19 #include "net/spdy/hpack/hpack_input_stream.h" | 19 #include "net/spdy/hpack/hpack_input_stream.h" |
20 #include "net/spdy/spdy_headers_handler_interface.h" | 20 #include "net/spdy/spdy_headers_handler_interface.h" |
21 #include "net/spdy/spdy_protocol.h" | 21 #include "net/spdy/spdy_protocol.h" |
22 | 22 |
23 // An HpackDecoder decodes header sets as outlined in | 23 // An HpackDecoder decodes header sets as outlined in |
24 // http://tools.ietf.org/html/rfc7541. | 24 // http://tools.ietf.org/html/rfc7541. |
25 | 25 |
26 namespace net { | 26 namespace net { |
27 | 27 |
28 class HpackHuffmanTable; | |
29 | |
30 namespace test { | 28 namespace test { |
31 class HpackDecoderPeer; | 29 class HpackDecoderPeer; |
32 } // namespace test | 30 } // namespace test |
33 | 31 |
34 class NET_EXPORT_PRIVATE HpackDecoder { | 32 class NET_EXPORT_PRIVATE HpackDecoder { |
35 public: | 33 public: |
36 friend class test::HpackDecoderPeer; | 34 friend class test::HpackDecoderPeer; |
37 | 35 |
38 // |table| is an initialized HPACK Huffman table, having an | 36 HpackDecoder(); |
39 // externally-managed lifetime which spans beyond HpackDecoder. | |
40 explicit HpackDecoder(const HpackHuffmanTable& table); | |
41 ~HpackDecoder(); | 37 ~HpackDecoder(); |
42 | 38 |
43 // Called upon acknowledgement of SETTINGS_HEADER_TABLE_SIZE. | 39 // Called upon acknowledgement of SETTINGS_HEADER_TABLE_SIZE. |
44 void ApplyHeaderTableSizeSetting(size_t size_setting) { | 40 void ApplyHeaderTableSizeSetting(size_t size_setting) { |
45 header_table_.SetSettingsHeaderTableSize(size_setting); | 41 header_table_.SetSettingsHeaderTableSize(size_setting); |
46 } | 42 } |
47 | 43 |
48 // If a SpdyHeadersHandlerInterface is provided, HpackDecoder will emit | 44 // If a SpdyHeadersHandlerInterface is provided, HpackDecoder will emit |
49 // headers to it rather than accumulating them in a SpdyHeaderBlock. | 45 // headers to it rather than accumulating them in a SpdyHeaderBlock. |
50 void HandleControlFrameHeadersStart(SpdyHeadersHandlerInterface* handler) { | 46 void HandleControlFrameHeadersStart(SpdyHeadersHandlerInterface* handler) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 91 |
96 const uint32_t max_string_literal_size_; | 92 const uint32_t max_string_literal_size_; |
97 HpackHeaderTable header_table_; | 93 HpackHeaderTable header_table_; |
98 | 94 |
99 // TODO(jgraettinger): Buffer for headers data, and storage for the last- | 95 // TODO(jgraettinger): Buffer for headers data, and storage for the last- |
100 // processed headers block. Both will be removed with the switch to | 96 // processed headers block. Both will be removed with the switch to |
101 // SpdyHeadersHandlerInterface. | 97 // SpdyHeadersHandlerInterface. |
102 std::string headers_block_buffer_; | 98 std::string headers_block_buffer_; |
103 SpdyHeaderBlock decoded_block_; | 99 SpdyHeaderBlock decoded_block_; |
104 | 100 |
105 // Huffman table to be applied to decoded Huffman literals, | 101 // Scratch space for storing decoded literals. |
106 // and scratch space for storing those decoded literals. | |
107 const HpackHuffmanTable& huffman_table_; | |
108 std::string key_buffer_, value_buffer_; | 102 std::string key_buffer_, value_buffer_; |
109 | 103 |
110 // If non-NULL, handles decoded headers. | 104 // If non-NULL, handles decoded headers. |
111 SpdyHeadersHandlerInterface* handler_; | 105 SpdyHeadersHandlerInterface* handler_; |
112 | 106 |
113 // Flag to keep track of having seen a regular header field. | 107 // Flag to keep track of having seen a regular header field. |
114 bool regular_header_seen_; | 108 bool regular_header_seen_; |
115 | 109 |
116 // Flag to keep track of having seen the header block start. | 110 // Flag to keep track of having seen the header block start. |
117 bool header_block_started_; | 111 bool header_block_started_; |
(...skipping 11 matching lines...) Expand all Loading... |
129 bool DecodeNextStringLiteral(HpackInputStream* input_stream, | 123 bool DecodeNextStringLiteral(HpackInputStream* input_stream, |
130 bool is_header_key, // As distinct from a value. | 124 bool is_header_key, // As distinct from a value. |
131 base::StringPiece* output); | 125 base::StringPiece* output); |
132 | 126 |
133 DISALLOW_COPY_AND_ASSIGN(HpackDecoder); | 127 DISALLOW_COPY_AND_ASSIGN(HpackDecoder); |
134 }; | 128 }; |
135 | 129 |
136 } // namespace net | 130 } // namespace net |
137 | 131 |
138 #endif // NET_SPDY_HPACK_DECODER_H_ | 132 #endif // NET_SPDY_HPACK_DECODER_H_ |
OLD | NEW |