| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // Returns |1 << indexed_length|. | 60 // Returns |1 << indexed_length|. |
| 61 size_t size() const; | 61 size_t size() const; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 HpackHuffmanTable(); | 64 HpackHuffmanTable(); |
| 65 ~HpackHuffmanTable(); | 65 ~HpackHuffmanTable(); |
| 66 | 66 |
| 67 // Prepares HpackHuffmanTable to encode & decode the canonical Huffman | 67 // Prepares HpackHuffmanTable to encode & decode the canonical Huffman |
| 68 // code as determined by the given symbols. Must be called exactly once. | 68 // code as determined by the given symbols. Must be called exactly once. |
| 69 // Returns false if the input symbols define an invalid coding, and true | 69 // Returns false if the input symbols define an invalid coding, and true |
| 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 // and |symbol_count| must fit in a uint16. |
| 71 bool Initialize(const Symbol* input_symbols, size_t symbol_count); | 72 bool Initialize(const Symbol* input_symbols, size_t symbol_count); |
| 72 | 73 |
| 73 // Returns whether Initialize() has been successfully called. | 74 // Returns whether Initialize() has been successfully called. |
| 74 bool IsInitialized() const; | 75 bool IsInitialized() const; |
| 75 | 76 |
| 76 // Encodes the input string to the output stream using the table's Huffman | 77 // Encodes the input string to the output stream using the table's Huffman |
| 77 // context. | 78 // context. |
| 78 void EncodeString(base::StringPiece in, HpackOutputStream* out) const; | 79 void EncodeString(base::StringPiece in, HpackOutputStream* out) const; |
| 79 | 80 |
| 80 // Returns the encoded size of the input string. | 81 // Returns the encoded size of the input string. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 uint8 pad_bits_; | 118 uint8 pad_bits_; |
| 118 | 119 |
| 119 // If initialization fails, preserve the symbol ID which failed validation | 120 // If initialization fails, preserve the symbol ID which failed validation |
| 120 // for examination in tests. | 121 // for examination in tests. |
| 121 uint16 failed_symbol_id_; | 122 uint16 failed_symbol_id_; |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 } // namespace net | 125 } // namespace net |
| 125 | 126 |
| 126 #endif // NET_SPDY_HPACK_HUFFMAN_TABLE_H_ | 127 #endif // NET_SPDY_HPACK_HUFFMAN_TABLE_H_ |
| OLD | NEW |