OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_DECODER_H_ | 5 #ifndef NET_SPDY_HPACK_HPACK_HUFFMAN_DECODER_H_ |
6 #define NET_SPDY_HPACK_HPACK_HUFFMAN_DECODER_H_ | 6 #define NET_SPDY_HPACK_HPACK_HUFFMAN_DECODER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 HpackHuffmanDecoder() = delete; | 28 HpackHuffmanDecoder() = delete; |
29 | 29 |
30 // Decodes a string that has been encoded using the HPACK Huffman Code (see | 30 // Decodes a string that has been encoded using the HPACK Huffman Code (see |
31 // https://httpwg.github.io/specs/rfc7541.html#huffman.code), reading the | 31 // https://httpwg.github.io/specs/rfc7541.html#huffman.code), reading the |
32 // encoded bitstream from |*in|, appending each decoded char to |*out|. | 32 // encoded bitstream from |*in|, appending each decoded char to |*out|. |
33 // To avoid repeatedly growing the |*out| string, the caller should reserve | 33 // To avoid repeatedly growing the |*out| string, the caller should reserve |
34 // sufficient space in |*out| to hold decoded output. | 34 // sufficient space in |*out| to hold decoded output. |
35 // DecodeString() halts when |in| runs out of input, in which case true is | 35 // DecodeString() halts when |in| runs out of input, in which case true is |
36 // returned. It also halts (returning false) if an invalid Huffman code | 36 // returned. It also halts (returning false) if an invalid Huffman code |
37 // prefix is read, or if |out_capacity| would otherwise be overflowed. | 37 // prefix is read. |
38 static bool DecodeString(HpackInputStream* in, | 38 static bool DecodeString(HpackInputStream* in, |
39 size_t out_capacity, | |
40 std::string* out); | 39 std::string* out); |
41 | 40 |
42 private: | 41 private: |
43 friend class test::HpackHuffmanDecoderPeer; | 42 friend class test::HpackHuffmanDecoderPeer; |
44 | 43 |
45 // The following private methods are declared here rather than simply | 44 // The following private methods are declared here rather than simply |
46 // inlined into DecodeString so that they can be tested directly. | 45 // inlined into DecodeString so that they can be tested directly. |
47 | 46 |
48 // Returns the length (in bits) of the HPACK Huffman code that starts with | 47 // Returns the length (in bits) of the HPACK Huffman code that starts with |
49 // the high bits of |value|. | 48 // the high bits of |value|. |
(...skipping 11 matching lines...) Expand all Loading... |
61 HuffmanWord bits); | 60 HuffmanWord bits); |
62 | 61 |
63 // Converts a canonical symbol to the source symbol (the char in the original | 62 // Converts a canonical symbol to the source symbol (the char in the original |
64 // string that was encoded). | 63 // string that was encoded). |
65 static char CanonicalToSource(HuffmanWord canonical); | 64 static char CanonicalToSource(HuffmanWord canonical); |
66 }; | 65 }; |
67 | 66 |
68 } // namespace net | 67 } // namespace net |
69 | 68 |
70 #endif // NET_SPDY_HPACK_HPACK_HUFFMAN_DECODER_H_ | 69 #endif // NET_SPDY_HPACK_HPACK_HUFFMAN_DECODER_H_ |
OLD | NEW |