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_CORE_HPACK_HPACK_HUFFMAN_TABLE_H_ | 5 #ifndef NET_SPDY_CORE_HPACK_HPACK_HUFFMAN_TABLE_H_ |
6 #define NET_SPDY_CORE_HPACK_HPACK_HUFFMAN_TABLE_H_ | 6 #define NET_SPDY_CORE_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 <vector> | 11 #include <vector> |
12 | 12 |
13 #include "net/base/net_export.h" | |
14 #include "net/spdy/core/hpack/hpack_constants.h" | 13 #include "net/spdy/core/hpack/hpack_constants.h" |
| 14 #include "net/spdy/platform/api/spdy_export.h" |
15 #include "net/spdy/platform/api/spdy_string.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; |
26 | 26 |
27 // HpackHuffmanTable encodes and decodes string literals using a constructed | 27 // HpackHuffmanTable encodes and decodes string literals using a constructed |
28 // canonical Huffman code. Once initialized, an instance is read only and | 28 // canonical Huffman code. Once initialized, an instance is read only and |
29 // may be accessed only through its const interface. | 29 // may be accessed only through its const interface. |
30 class NET_EXPORT_PRIVATE HpackHuffmanTable { | 30 class SPDY_EXPORT_PRIVATE HpackHuffmanTable { |
31 public: | 31 public: |
32 friend class test::HpackHuffmanTablePeer; | 32 friend class test::HpackHuffmanTablePeer; |
33 | 33 |
34 typedef HpackHuffmanSymbol Symbol; | 34 typedef HpackHuffmanSymbol Symbol; |
35 | 35 |
36 // DecodeTables are multilevel indexes on code prefixes. Each table indexes | 36 // DecodeTables are multilevel indexes on code prefixes. Each table indexes |
37 // a portion of the prefix mapped to DecodeEntry, which in turn either | 37 // a portion of the prefix mapped to DecodeEntry, which in turn either |
38 // captures a terminal symbol, or points to the next DecodeTable to consult | 38 // captures a terminal symbol, or points to the next DecodeTable to consult |
39 // with successive portions of the prefix. | 39 // with successive portions of the prefix. |
40 struct NET_EXPORT_PRIVATE DecodeEntry { | 40 struct SPDY_EXPORT_PRIVATE DecodeEntry { |
41 DecodeEntry(); | 41 DecodeEntry(); |
42 DecodeEntry(uint8_t next_table_index, uint8_t length, uint16_t symbol_id); | 42 DecodeEntry(uint8_t next_table_index, uint8_t length, uint16_t symbol_id); |
43 | 43 |
44 // The next table to consult. If this is a terminal, | 44 // The next table to consult. If this is a terminal, |
45 // |next_table_index| will be self-referential. | 45 // |next_table_index| will be self-referential. |
46 uint8_t next_table_index; | 46 uint8_t next_table_index; |
47 // Bit-length of terminal code, if this is a terminal. Length of the | 47 // Bit-length of terminal code, if this is a terminal. Length of the |
48 // longest code having this prefix, if non-terminal. | 48 // longest code having this prefix, if non-terminal. |
49 uint8_t length; | 49 uint8_t length; |
50 // Set only for terminal entries. | 50 // Set only for terminal entries. |
51 uint16_t symbol_id; | 51 uint16_t symbol_id; |
52 }; | 52 }; |
53 struct NET_EXPORT_PRIVATE DecodeTable { | 53 struct SPDY_EXPORT_PRIVATE DecodeTable { |
54 // Number of bits indexed by the chain leading to this table. | 54 // Number of bits indexed by the chain leading to this table. |
55 uint8_t prefix_length; | 55 uint8_t prefix_length; |
56 // Number of additional prefix bits this table indexes. | 56 // Number of additional prefix bits this table indexes. |
57 uint8_t indexed_length; | 57 uint8_t indexed_length; |
58 // Entries are represented as a length |size()| slice into | 58 // Entries are represented as a length |size()| slice into |
59 // |decode_entries_| beginning at |entries_offset|. | 59 // |decode_entries_| beginning at |entries_offset|. |
60 size_t entries_offset; | 60 size_t entries_offset; |
61 // Returns |1 << indexed_length|. | 61 // Returns |1 << indexed_length|. |
62 size_t size() const; | 62 size_t size() const; |
63 }; | 63 }; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 uint8_t pad_bits_; | 125 uint8_t pad_bits_; |
126 | 126 |
127 // If initialization fails, preserve the symbol ID which failed validation | 127 // If initialization fails, preserve the symbol ID which failed validation |
128 // for examination in tests. | 128 // for examination in tests. |
129 uint16_t failed_symbol_id_; | 129 uint16_t failed_symbol_id_; |
130 }; | 130 }; |
131 | 131 |
132 } // namespace net | 132 } // namespace net |
133 | 133 |
134 #endif // NET_SPDY_CORE_HPACK_HPACK_HUFFMAN_TABLE_H_ | 134 #endif // NET_SPDY_CORE_HPACK_HPACK_HUFFMAN_TABLE_H_ |
OLD | NEW |