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_HPACK_HUFFMAN_TABLE_H_ | 5 #ifndef NET_SPDY_HPACK_HPACK_HUFFMAN_TABLE_H_ |
6 #define NET_SPDY_HPACK_HPACK_HUFFMAN_TABLE_H_ | 6 #define NET_SPDY_HPACK_HPACK_HUFFMAN_TABLE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <cstddef> | 10 #include <cstddef> |
11 #include <string> | |
12 #include <vector> | 11 #include <vector> |
13 | 12 |
14 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
15 #include "net/spdy/hpack/hpack_constants.h" | 14 #include "net/spdy/hpack/hpack_constants.h" |
| 15 #include "net/spdy/platform/api/spdy_string.h" |
16 #include "net/spdy/platform/api/spdy_string_piece.h" | 16 #include "net/spdy/platform/api/spdy_string_piece.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 namespace test { | 20 namespace test { |
21 class HpackHuffmanTablePeer; | 21 class HpackHuffmanTablePeer; |
22 } // namespace test | 22 } // namespace test |
23 | 23 |
24 class HpackInputStream; | 24 class HpackInputStream; |
25 class HpackOutputStream; | 25 class HpackOutputStream; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 // Decodes symbols from |in| into |out|, using the support for generic (any) | 85 // Decodes symbols from |in| into |out|, using the support for generic (any) |
86 // huffman tables, not just those defined in the HPACK spec. It is the | 86 // huffman tables, not just those defined in the HPACK spec. It is the |
87 // caller's responsibility to ensure |out| has reserved a sufficient buffer to | 87 // caller's responsibility to ensure |out| has reserved a sufficient buffer to |
88 // hold decoded output. GenericDecodeString() halts when |in| runs out of | 88 // hold decoded output. GenericDecodeString() halts when |in| runs out of |
89 // input, in which case true is returned. It also halts (returning false) if | 89 // input, in which case true is returned. It also halts (returning false) if |
90 // an invalid Huffman code prefix is read, or if |out_capacity| would | 90 // an invalid Huffman code prefix is read, or if |out_capacity| would |
91 // otherwise be overflowed. | 91 // otherwise be overflowed. |
92 // DEPRECATED: HpackHuffmanDecoder is now used for decoding strings encoded | 92 // DEPRECATED: HpackHuffmanDecoder is now used for decoding strings encoded |
93 // according to the Huffman Table in the HPACK spec. | 93 // according to the Huffman Table in the HPACK spec. |
94 bool GenericDecodeString(HpackInputStream* in, | 94 bool GenericDecodeString(HpackInputStream* in, SpdyString* out) const; |
95 std::string* out) const; | |
96 | 95 |
97 // Returns the estimate of dynamically allocated memory in bytes. | 96 // Returns the estimate of dynamically allocated memory in bytes. |
98 size_t EstimateMemoryUsage() const; | 97 size_t EstimateMemoryUsage() const; |
99 | 98 |
100 private: | 99 private: |
101 // Expects symbols ordered on length & ID ascending. | 100 // Expects symbols ordered on length & ID ascending. |
102 void BuildDecodeTables(const std::vector<Symbol>& symbols); | 101 void BuildDecodeTables(const std::vector<Symbol>& symbols); |
103 | 102 |
104 // Expects symbols ordered on ID ascending. | 103 // Expects symbols ordered on ID ascending. |
105 void BuildEncodeTable(const std::vector<Symbol>& symbols); | 104 void BuildEncodeTable(const std::vector<Symbol>& symbols); |
(...skipping 20 matching lines...) Expand all Loading... |
126 uint8_t pad_bits_; | 125 uint8_t pad_bits_; |
127 | 126 |
128 // If initialization fails, preserve the symbol ID which failed validation | 127 // If initialization fails, preserve the symbol ID which failed validation |
129 // for examination in tests. | 128 // for examination in tests. |
130 uint16_t failed_symbol_id_; | 129 uint16_t failed_symbol_id_; |
131 }; | 130 }; |
132 | 131 |
133 } // namespace net | 132 } // namespace net |
134 | 133 |
135 #endif // NET_SPDY_HPACK_HPACK_HUFFMAN_TABLE_H_ | 134 #endif // NET_SPDY_HPACK_HPACK_HUFFMAN_TABLE_H_ |
OLD | NEW |