We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / net / spdy / hpack_constants.h
blob16fccfe4d1a1afc2829c41628b0bfe08b68129b0
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
3 // found in the LICENSE file.
5 #ifndef NET_SPDY_HPACK_CONSTANTS_H_
6 #define NET_SPDY_HPACK_CONSTANTS_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "net/base/net_export.h"
13 // All section references below are to
14 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08
16 namespace net {
18 // An HpackPrefix signifies |bits| stored in the top |bit_size| bits
19 // of an octet.
20 struct HpackPrefix {
21 uint8 bits;
22 size_t bit_size;
25 // Represents a symbol and its Huffman code (stored in most-significant bits).
26 struct HpackHuffmanSymbol {
27 uint32 code;
28 uint8 length;
29 uint16 id;
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;
41 class HpackHuffmanTable;
42 class HpackStaticTable;
44 const uint32 kDefaultHeaderTableSizeSetting = 4096;
46 // Largest string literal an HpackDecoder/HpackEncoder will attempt to process
47 // before returning an error.
48 const uint32 kDefaultMaxStringLiteralSize = 16 * 1024;
50 // Maximum amount of encoded header buffer HpackDecoder will retain before
51 // returning an error.
52 // TODO(jgraettinger): Remove with SpdyHeadersHandlerInterface switch.
53 const uint32 kMaxDecodeBufferSize = 32 * 1024;
55 // 6.2: Flag for a string literal that is stored unmodified (i.e.,
56 // without Huffman encoding).
57 const HpackPrefix kStringLiteralIdentityEncoded = { 0x0, 1 };
59 // 6.2: Flag for a Huffman-coded string literal.
60 const HpackPrefix kStringLiteralHuffmanEncoded = { 0x1, 1 };
62 // 7.1: Opcode for an indexed header field.
63 const HpackPrefix kIndexedOpcode = { 0x1, 1 };
65 // 7.2.1: Opcode for a literal header field with incremental indexing.
66 const HpackPrefix kLiteralIncrementalIndexOpcode = { 0x1, 2 };
68 // 7.2.2: Opcode for a literal header field without indexing.
69 const HpackPrefix kLiteralNoIndexOpcode = { 0x0, 4 };
71 // 7.2.3: Opcode for a literal header field which is never indexed.
72 const HpackPrefix kLiteralNeverIndexOpcode = { 0x1, 4 };
74 // 7.3: Opcode for maximum header table size update. Begins a varint-encoded
75 // table size with a 5-bit prefix.
76 const HpackPrefix kHeaderTableSizeUpdateOpcode = { 0x1, 3 };
78 // Returns symbol code table from "Appendix C. Huffman Code".
79 NET_EXPORT_PRIVATE std::vector<HpackHuffmanSymbol> HpackHuffmanCode();
81 // Returns static table from "Appendix B. Static Table Definition".
82 NET_EXPORT_PRIVATE std::vector<HpackStaticEntry> HpackStaticTableVector();
84 // Returns a HpackHuffmanTable instance initialized with |kHpackHuffmanCode|.
85 // The instance is read-only, has static lifetime, and is safe to share amoung
86 // threads. This function is thread-safe.
87 NET_EXPORT_PRIVATE const HpackHuffmanTable& ObtainHpackHuffmanTable();
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();
94 // Pseudo-headers start with a colon. (HTTP2 8.1.2.1., HPACK 3.1.)
95 const char kPseudoHeaderPrefix = ':';
97 } // namespace net
99 #endif // NET_SPDY_HPACK_CONSTANTS_H_