Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: net/spdy/hpack/hpack_huffman_decoder.h

Issue 2801603003: Add SpdyString alias for std::string in net/spdy. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/hpack/hpack_header_table_test.cc ('k') | net/spdy/hpack/hpack_huffman_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include <string>
12
13 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
14 #include "net/spdy/hpack/hpack_input_stream.h" 12 #include "net/spdy/hpack/hpack_input_stream.h"
13 #include "net/spdy/platform/api/spdy_string.h"
15 14
16 namespace net { 15 namespace net {
17 namespace test { 16 namespace test {
18 class HpackHuffmanDecoderPeer; 17 class HpackHuffmanDecoderPeer;
19 } // namespace test 18 } // namespace test
20 19
21 // Declared as a class to simplify testing. 20 // Declared as a class to simplify testing.
22 // No instances are actually allocated. 21 // No instances are actually allocated.
23 class NET_EXPORT_PRIVATE HpackHuffmanDecoder { 22 class NET_EXPORT_PRIVATE HpackHuffmanDecoder {
24 public: 23 public:
25 typedef uint32_t HuffmanWord; 24 typedef uint32_t HuffmanWord;
26 typedef size_t HuffmanCodeLength; 25 typedef size_t HuffmanCodeLength;
27 26
28 HpackHuffmanDecoder() = delete; 27 HpackHuffmanDecoder() = delete;
29 28
30 // Decodes a string that has been encoded using the HPACK Huffman Code (see 29 // 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 30 // https://httpwg.github.io/specs/rfc7541.html#huffman.code), reading the
32 // encoded bitstream from |*in|, appending each decoded char to |*out|. 31 // encoded bitstream from |*in|, appending each decoded char to |*out|.
33 // To avoid repeatedly growing the |*out| string, the caller should reserve 32 // To avoid repeatedly growing the |*out| string, the caller should reserve
34 // sufficient space in |*out| to hold decoded output. 33 // sufficient space in |*out| to hold decoded output.
35 // DecodeString() halts when |in| runs out of input, in which case true is 34 // 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 35 // returned. It also halts (returning false) if an invalid Huffman code
37 // prefix is read. 36 // prefix is read.
38 static bool DecodeString(HpackInputStream* in, std::string* out); 37 static bool DecodeString(HpackInputStream* in, SpdyString* out);
39 38
40 private: 39 private:
41 friend class test::HpackHuffmanDecoderPeer; 40 friend class test::HpackHuffmanDecoderPeer;
42 41
43 // The following private methods are declared here rather than simply 42 // The following private methods are declared here rather than simply
44 // inlined into DecodeString so that they can be tested directly. 43 // inlined into DecodeString so that they can be tested directly.
45 44
46 // Returns the length (in bits) of the HPACK Huffman code that starts with 45 // Returns the length (in bits) of the HPACK Huffman code that starts with
47 // the high bits of |value|. 46 // the high bits of |value|.
48 static HuffmanCodeLength CodeLengthOfPrefix(HuffmanWord value); 47 static HuffmanCodeLength CodeLengthOfPrefix(HuffmanWord value);
(...skipping 10 matching lines...) Expand all
59 HuffmanWord bits); 58 HuffmanWord bits);
60 59
61 // Converts a canonical symbol to the source symbol (the char in the original 60 // Converts a canonical symbol to the source symbol (the char in the original
62 // string that was encoded). 61 // string that was encoded).
63 static char CanonicalToSource(HuffmanWord canonical); 62 static char CanonicalToSource(HuffmanWord canonical);
64 }; 63 };
65 64
66 } // namespace net 65 } // namespace net
67 66
68 #endif // NET_SPDY_HPACK_HPACK_HUFFMAN_DECODER_H_ 67 #endif // NET_SPDY_HPACK_HPACK_HUFFMAN_DECODER_H_
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_header_table_test.cc ('k') | net/spdy/hpack/hpack_huffman_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698