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_HUFFMAN_TABLE_H_ | 5 #ifndef NET_SPDY_HPACK_HUFFMAN_TABLE_H_ |
6 #define NET_SPDY_HPACK_HUFFMAN_TABLE_H_ | 6 #define NET_SPDY_HPACK_HUFFMAN_TABLE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <cstddef> | 10 #include <cstddef> |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Returns whether Initialize() has been successfully called. | 75 // Returns whether Initialize() has been successfully called. |
76 bool IsInitialized() const; | 76 bool IsInitialized() const; |
77 | 77 |
78 // Encodes the input string to the output stream using the table's Huffman | 78 // Encodes the input string to the output stream using the table's Huffman |
79 // context. | 79 // context. |
80 void EncodeString(base::StringPiece in, HpackOutputStream* out) const; | 80 void EncodeString(base::StringPiece in, HpackOutputStream* out) const; |
81 | 81 |
82 // Returns the encoded size of the input string. | 82 // Returns the encoded size of the input string. |
83 size_t EncodedSize(base::StringPiece in) const; | 83 size_t EncodedSize(base::StringPiece in) const; |
84 | 84 |
85 // Decodes symbols from |in| into |out|. It is the caller's responsibility | 85 // Decodes symbols from |in| into |out|, using the support for generic (any) |
86 // to ensure |out| has a reserved a sufficient buffer to hold decoded output. | 86 // huffman tables, not just those defined in the HPACK spec. It is the |
87 // DecodeString() halts when |in| runs out of input, in which case true is | 87 // caller's responsibility to ensure |out| has reserved a sufficient buffer to |
88 // returned. It also halts (returning false) if an invalid Huffman code | 88 // hold decoded output. GenericDecodeString() halts when |in| runs out of |
89 // prefix is read, or if |out_capacity| would otherwise be overflowed. | 89 // input, in which case true is returned. It also halts (returning false) if |
90 bool DecodeString(HpackInputStream* in, | 90 // an invalid Huffman code prefix is read, or if |out_capacity| would |
91 size_t out_capacity, | 91 // otherwise be overflowed. |
92 std::string* out) const; | 92 // DEPRECATED: HpackHuffmanDecoder is now used for decoding strings encoded |
| 93 // according to the Huffman Table in the HPACK spec. |
| 94 bool GenericDecodeString(HpackInputStream* in, |
| 95 size_t out_capacity, |
| 96 std::string* out) const; |
93 | 97 |
94 private: | 98 private: |
95 // Expects symbols ordered on length & ID ascending. | 99 // Expects symbols ordered on length & ID ascending. |
96 void BuildDecodeTables(const std::vector<Symbol>& symbols); | 100 void BuildDecodeTables(const std::vector<Symbol>& symbols); |
97 | 101 |
98 // Expects symbols ordered on ID ascending. | 102 // Expects symbols ordered on ID ascending. |
99 void BuildEncodeTable(const std::vector<Symbol>& symbols); | 103 void BuildEncodeTable(const std::vector<Symbol>& symbols); |
100 | 104 |
101 // Adds a new DecodeTable with the argument prefix & indexed length. | 105 // Adds a new DecodeTable with the argument prefix & indexed length. |
102 // Returns the new table index. | 106 // Returns the new table index. |
(...skipping 17 matching lines...) Expand all Loading... |
120 uint8_t pad_bits_; | 124 uint8_t pad_bits_; |
121 | 125 |
122 // If initialization fails, preserve the symbol ID which failed validation | 126 // If initialization fails, preserve the symbol ID which failed validation |
123 // for examination in tests. | 127 // for examination in tests. |
124 uint16_t failed_symbol_id_; | 128 uint16_t failed_symbol_id_; |
125 }; | 129 }; |
126 | 130 |
127 } // namespace net | 131 } // namespace net |
128 | 132 |
129 #endif // NET_SPDY_HPACK_HUFFMAN_TABLE_H_ | 133 #endif // NET_SPDY_HPACK_HUFFMAN_TABLE_H_ |
OLD | NEW |