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

Side by Side Diff: net/spdy/hpack_constants.h

Issue 549583003: Make HPACK static table static and immutable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/net.gypi ('k') | net/spdy/hpack_constants.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 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_CONSTANTS_H_ 5 #ifndef NET_SPDY_HPACK_CONSTANTS_H_
6 #define NET_SPDY_HPACK_CONSTANTS_H_ 6 #define NET_SPDY_HPACK_CONSTANTS_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 11 matching lines...) Expand all
22 size_t bit_size; 22 size_t bit_size;
23 }; 23 };
24 24
25 // Represents a symbol and its Huffman code (stored in most-significant bits). 25 // Represents a symbol and its Huffman code (stored in most-significant bits).
26 struct HpackHuffmanSymbol { 26 struct HpackHuffmanSymbol {
27 uint32 code; 27 uint32 code;
28 uint8 length; 28 uint8 length;
29 uint16 id; 29 uint16 id;
30 }; 30 };
31 31
32 // An entry in the static table. Must be a POD in order to avoid static
33 // initializers, i.e. no user-defined constructors or destructors.
34 struct HpackStaticEntry {
35 const char* const name;
36 const size_t name_len;
37 const char* const value;
38 const size_t value_len;
39 };
40
32 class HpackHuffmanTable; 41 class HpackHuffmanTable;
42 class HpackStaticTable;
33 43
34 const uint32 kDefaultHeaderTableSizeSetting = 4096; 44 const uint32 kDefaultHeaderTableSizeSetting = 4096;
35 45
36 // Largest string literal an HpackDecoder/HpackEncoder will attempt to process 46 // Largest string literal an HpackDecoder/HpackEncoder will attempt to process
37 // before returning an error. 47 // before returning an error.
38 const uint32 kDefaultMaxStringLiteralSize = 16 * 1024; 48 const uint32 kDefaultMaxStringLiteralSize = 16 * 1024;
39 49
40 // Maximum amount of encoded header buffer HpackDecoder will retain before 50 // Maximum amount of encoded header buffer HpackDecoder will retain before
41 // returning an error. 51 // returning an error.
42 // TODO(jgraettinger): Remove with SpdyHeadersHandlerInterface switch. 52 // TODO(jgraettinger): Remove with SpdyHeadersHandlerInterface switch.
(...skipping 15 matching lines...) Expand all
58 // 7.2.2: Opcode for a literal header field without indexing. 68 // 7.2.2: Opcode for a literal header field without indexing.
59 const HpackPrefix kLiteralNoIndexOpcode = { 0x0, 4 }; 69 const HpackPrefix kLiteralNoIndexOpcode = { 0x0, 4 };
60 70
61 // 7.2.3: Opcode for a literal header field which is never indexed. 71 // 7.2.3: Opcode for a literal header field which is never indexed.
62 const HpackPrefix kLiteralNeverIndexOpcode = { 0x1, 4 }; 72 const HpackPrefix kLiteralNeverIndexOpcode = { 0x1, 4 };
63 73
64 // 7.3: Opcode for maximum header table size update. Begins a varint-encoded 74 // 7.3: Opcode for maximum header table size update. Begins a varint-encoded
65 // table size with a 5-bit prefix. 75 // table size with a 5-bit prefix.
66 const HpackPrefix kHeaderTableSizeUpdateOpcode = { 0x1, 3 }; 76 const HpackPrefix kHeaderTableSizeUpdateOpcode = { 0x1, 3 };
67 77
68 // Returns symbol code table from "Appendix C. Huffman Codes". 78 // Returns symbol code table from "Appendix C. Huffman Code".
69 NET_EXPORT_PRIVATE std::vector<HpackHuffmanSymbol> HpackHuffmanCode(); 79 NET_EXPORT_PRIVATE std::vector<HpackHuffmanSymbol> HpackHuffmanCode();
70 80
81 // Returns static table from "Appendix B. Static Table Definition".
82 NET_EXPORT_PRIVATE std::vector<HpackStaticEntry> HpackStaticTableVector();
83
71 // Returns a HpackHuffmanTable instance initialized with |kHpackHuffmanCode|. 84 // Returns a HpackHuffmanTable instance initialized with |kHpackHuffmanCode|.
72 // The instance is read-only, has static lifetime, and is safe to share amoung 85 // The instance is read-only, has static lifetime, and is safe to share amoung
73 // threads. This function is thread-safe. 86 // threads. This function is thread-safe.
74 NET_EXPORT_PRIVATE const HpackHuffmanTable& ObtainHpackHuffmanTable(); 87 NET_EXPORT_PRIVATE const HpackHuffmanTable& ObtainHpackHuffmanTable();
75 88
89 // Returns a HpackStaticTable instance initialized with |kHpackStaticTable|.
90 // The instance is read-only, has static lifetime, and is safe to share amoung
91 // threads. This function is thread-safe.
92 NET_EXPORT_PRIVATE const HpackStaticTable& ObtainHpackStaticTable();
93
76 // Pseudo-headers start with a colon. (HTTP2 8.1.2.1., HPACK 3.1.) 94 // Pseudo-headers start with a colon. (HTTP2 8.1.2.1., HPACK 3.1.)
77 const char kPseudoHeaderPrefix = ':'; 95 const char kPseudoHeaderPrefix = ':';
78 96
79 } // namespace net 97 } // namespace net
80 98
81 #endif // NET_SPDY_HPACK_CONSTANTS_H_ 99 #endif // NET_SPDY_HPACK_CONSTANTS_H_
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/spdy/hpack_constants.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698