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

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

Issue 22074002: DO NOT COMMIT: Implement HPACK (draft 03) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update for httpbis-draft-06 / hpack-draft-03 Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/http2_decompressor_unittest.cc ('k') | net/spdy/http2_encoding_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 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.
4
5 #ifndef NET_SPDY_HTTP2_ENCODING_CONTEXT_H_
6 #define NET_SPDY_HTTP2_ENCODING_CONTEXT_H_
7
8 #include <cstddef>
9 #include <deque>
10 #include <string>
11 #include <vector>
12
13 #include "base/basictypes.h"
14
15 namespace net {
16
17 extern const uint8 kIndexOpcode;
18 extern const uint8 kIndexN;
19
20 extern const uint8 kLiteralNoIndexOpcode;
21 extern const uint8 kLiteralNoIndexN;
22
23 extern const uint8 kLiteralIncrementalOpcode;
24 extern const uint8 kLiteralIncrementalN;
25
26 extern const uint8 kLiteralSubstitutionOpcode;
27 extern const uint8 kLiteralSubstitutionN;
28
29 extern const uint32 kUntouched;
30
31 enum Http2Direction {
32 HTTP2_REQUEST,
33 HTTP2_RESPONSE
34 };
35
36 bool IsValidHeaderName(const std::string& str);
37
38 bool IsValidHeaderValue(const std::string& str);
39
40 bool StringsEqualConstantTime(const std::string& str1,
41 const std::string& str2);
42
43 struct HeaderTableEntry {
44 HeaderTableEntry();
45 HeaderTableEntry(const std::string& name, const std::string& value);
46
47 bool Equals(const HeaderTableEntry& other) const;
48
49 size_t Size() const;
50
51 std::string name;
52 std::string value;
53
54 bool referenced;
55 uint32 touch_count;
56 };
57
58 class HeaderTable {
59 public:
60 HeaderTable();
61
62 ~HeaderTable();
63
64 size_t GetEntryCount() const;
65
66 void SetMaxSize(size_t max_size);
67
68 const HeaderTableEntry* GetEntry(int32 index) const;
69
70 HeaderTableEntry* GetMutableEntry(int32 index);
71
72 void TryAppendEntry(const HeaderTableEntry& entry,
73 int32* index,
74 std::vector<uint32>* removed_referenced_indices);
75
76 void TryReplaceEntry(uint32 substituted_index,
77 const HeaderTableEntry& entry,
78 int32* index,
79 std::vector<uint32>* removed_referenced_indices);
80
81 private:
82 void RemoveFirstEntry();
83
84 std::deque<HeaderTableEntry> entries_;
85 size_t size_;
86 size_t max_size_;
87
88 DISALLOW_COPY_AND_ASSIGN(HeaderTable);
89 };
90
91 class EncodingContext {
92 public:
93 EncodingContext(Http2Direction direction);
94
95 ~EncodingContext();
96
97 size_t GetEntryCount() const;
98
99 bool IsReferenced(uint32 index) const;
100
101 bool GetIndexedHeaderName(uint32 index, std::string* name) const;
102
103 bool GetIndexedHeaderValue(uint32 index, std::string* value) const;
104
105 void ProcessIndexedHeader(uint32 index);
106
107 void ProcessLiteralHeaderWithIncrementalIndexing(
108 const std::string& name,
109 const std::string& value,
110 int32* index,
111 std::vector<uint32>* removed_referenced_indices);
112
113 void ProcessLiteralHeaderWithSubstitutionIndexing(
114 const std::string& name,
115 uint32 substituted_index,
116 const std::string& value,
117 int32* index,
118 std::vector<uint32>* removed_referenced_indices);
119
120 void AddTouches(uint32 index, uint32 touch_count);
121
122 HeaderTableEntry* GetMutableEntry(int32 index);
123
124 private:
125 HeaderTable header_table_;
126
127 DISALLOW_COPY_AND_ASSIGN(EncodingContext);
128 };
129
130 } // namespace net
131
132 #endif // NET_SPDY_HTTP2_ENCODING_CONTEXT_H_
OLDNEW
« no previous file with comments | « net/spdy/http2_decompressor_unittest.cc ('k') | net/spdy/http2_encoding_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698