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

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

Issue 138243003: Implement basic classes for HPACK (HTTP/2 compression) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: And removing tabs from net.gyp... Created 6 years, 11 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
OLDNEW
(Empty)
1 #ifndef NET_SPDY_HPACK_ENCODING_CONTEXT_H_
2 #define NET_SPDY_HPACK_ENCODING_CONTEXT_H_
3
4 #include <cstddef>
5 #include <deque>
6 #include <vector>
7
8 #include "base/basictypes.h"
9 #include "base/macros.h"
10 #include "base/strings/string_piece.h"
11 #include "net/spdy/hpack_header_table.h"
12
13 // All section references below are to
14 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-04
15 // .
16
17 namespace net {
18
19 // An encoding context is simply a header table and its associated
20 // reference set and a static table.
21 class HpackEncodingContext {
22 public:
23 // The constant returned by GetTouchesAt() if the indexed entry
24 // hasn't been touched (which is distinct from having a touch count
25 // of 0).
26 //
27 // TODO(akalin): The distinction between untouched and having a
28 // touch count of 0 is confusing. Think of a better way to represent
29 // this state.
30 static const uint32 kUntouched;
31
32 HpackEncodingContext();
33
34 ~HpackEncodingContext();
35
36 uint32 GetEntryCount() const;
37
38 // For all accessor below, index must be < GetEntryCount().
39
40 // The StringPieces returned by Get{Name,Value}At() live as long as
41 // the next call to SetMaxSize() or the Process*() functions.
42
43 base::StringPiece GetNameAt(uint32 index) const;
44
45 base::StringPiece GetValueAt(uint32 index) const;
46
47 bool IsReferencedAt(uint32 index) const;
48
49 uint32 GetTouchCountAt(uint32 index) const;
50
51 void SetReferencedAt(uint32 index, bool referenced);
52
53 // Adds the given number of touches to the entry at the given
54 // index. It is guaranteed that GetTouchCountAt(index) will not
55 // equal kUntouched after this function is called (even if
56 // touch_count == 0).
57 void AddTouchesAt(uint32 index, uint32 touch_count);
58
59 // Sets the touch count of the entry at the given index to
60 // kUntouched.
61 void ClearTouchesAt(uint32 index);
62
63 // Sets the maximum size of the encoding text, evicting entries if
64 // necessary.
65 void SetMaxSize(uint32 max_size);
66
67 // The Process*() functions below return true on success and false
68 // if an error was encountered.
69
70 // Tries to update the encoding context given an indexed header
71 // opcode for the given index as described in 3.2.1. new_index is
72 // filled in with the index of a mutable entry, or -1 if one was not
73 // able to be created. removed_referenced_indices is filled in with
74 // the indices of all entries removed from the reference set.
75 bool ProcessIndexedHeader(uint32 index,
76 int32* new_index,
77 std::vector<uint32>* removed_referenced_indices);
78
79 // Tries to update the encoding context given a literal header with
80 // incremental indexing opcode for the given name and value as
81 // described in 3.2.1. index is filled in with the index of the new
82 // entry if the header was successfully indexed, or -1 if
83 // not. removed_referenced_indices is filled in with the indices of
84 // all entries removed from the reference set.
85 bool ProcessLiteralHeaderWithIncrementalIndexing(
86 base::StringPiece name,
87 base::StringPiece value,
88 int32* index,
89 std::vector<uint32>* removed_referenced_indices);
90
91 private:
92 HpackHeaderTable header_table_;
93
94 DISALLOW_COPY_AND_ASSIGN(HpackEncodingContext);
95 };
96
97 } // namespace net
98
99 #endif // NET_SPDY_HPACK_ENCODING_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698