| 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 <cstddef> | 8 #include <cstddef> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // otherwise. Symbols must be presented in ascending ID order with no gaps. | 70 // otherwise. Symbols must be presented in ascending ID order with no gaps. |
| 71 bool Initialize(const Symbol* input_symbols, size_t symbol_count); | 71 bool Initialize(const Symbol* input_symbols, size_t symbol_count); |
| 72 | 72 |
| 73 // Returns whether Initialize() has been successfully called. | 73 // Returns whether Initialize() has been successfully called. |
| 74 bool IsInitialized() const; | 74 bool IsInitialized() const; |
| 75 | 75 |
| 76 // Encodes the input string to the output stream using the table's Huffman | 76 // Encodes the input string to the output stream using the table's Huffman |
| 77 // context. | 77 // context. |
| 78 void EncodeString(base::StringPiece in, HpackOutputStream* out) const; | 78 void EncodeString(base::StringPiece in, HpackOutputStream* out) const; |
| 79 | 79 |
| 80 // Returns the encoded size of the input string. |
| 81 size_t EncodedSize(base::StringPiece in) const; |
| 82 |
| 80 // Decodes symbols from |in| into |out|. It is the caller's responsibility | 83 // Decodes symbols from |in| into |out|. It is the caller's responsibility |
| 81 // to ensure |out| has a reserved a sufficient buffer to hold decoded output. | 84 // to ensure |out| has a reserved a sufficient buffer to hold decoded output. |
| 82 // DecodeString() halts when |in| runs out of input, in which case true is | 85 // DecodeString() halts when |in| runs out of input, in which case true is |
| 83 // returned. It also halts (returning false) if an invalid Huffman code | 86 // returned. It also halts (returning false) if an invalid Huffman code |
| 84 // prefix is read, or if |out_capacity| would otherwise be overflowed. | 87 // prefix is read, or if |out_capacity| would otherwise be overflowed. |
| 85 bool DecodeString(HpackInputStream* in, | 88 bool DecodeString(HpackInputStream* in, |
| 86 size_t out_capacity, | 89 size_t out_capacity, |
| 87 std::string* out) const; | 90 std::string* out) const; |
| 88 | 91 |
| 89 private: | 92 private: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 114 uint8 pad_bits_; | 117 uint8 pad_bits_; |
| 115 | 118 |
| 116 // If initialization fails, preserve the symbol ID which failed validation | 119 // If initialization fails, preserve the symbol ID which failed validation |
| 117 // for examination in tests. | 120 // for examination in tests. |
| 118 uint16 failed_symbol_id_; | 121 uint16 failed_symbol_id_; |
| 119 }; | 122 }; |
| 120 | 123 |
| 121 } // namespace net | 124 } // namespace net |
| 122 | 125 |
| 123 #endif // NET_SPDY_HPACK_HUFFMAN_TABLE_H_ | 126 #endif // NET_SPDY_HPACK_HUFFMAN_TABLE_H_ |
| OLD | NEW |