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

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

Issue 145353017: Update HPACK implementation to draft 05 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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/hpack_encoder.h ('k') | net/spdy/hpack_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
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_ENCODING_CONTEXT_H_ 5 #ifndef NET_SPDY_HPACK_ENCODING_CONTEXT_H_
6 #define NET_SPDY_HPACK_ENCODING_CONTEXT_H_ 6 #define NET_SPDY_HPACK_ENCODING_CONTEXT_H_
7 7
8 #include <cstddef> 8 #include <cstddef>
9 #include <deque> 9 #include <deque>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
16 #include "net/spdy/hpack_header_table.h" 16 #include "net/spdy/hpack_header_table.h"
17 17
18 // All section references below are to 18 // All section references below are to
19 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-04 19 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05
20 // . 20 // .
21 21
22 namespace net { 22 namespace net {
23 23
24 // An encoding context is simply a header table and its associated 24 // An encoding context is simply a header table and its associated
25 // reference set and a static table. 25 // reference set and a static table.
26 class NET_EXPORT_PRIVATE HpackEncodingContext { 26 class NET_EXPORT_PRIVATE HpackEncodingContext {
27 public: 27 public:
28 // The constant returned by GetTouchesAt() if the indexed entry 28 // The constant returned by GetTouchesAt() if the indexed entry
29 // hasn't been touched (which is distinct from having a touch count 29 // hasn't been touched (which is distinct from having a touch count
30 // of 0). 30 // of 0).
31 // 31 //
32 // TODO(akalin): The distinction between untouched and having a 32 // TODO(akalin): The distinction between untouched and having a
33 // touch count of 0 is confusing. Think of a better way to represent 33 // touch count of 0 is confusing. Think of a better way to represent
34 // this state. 34 // this state.
35 static const uint32 kUntouched; 35 static const uint32 kUntouched;
36 36
37 HpackEncodingContext(); 37 HpackEncodingContext();
38 38
39 ~HpackEncodingContext(); 39 ~HpackEncodingContext();
40 40
41 uint32 GetMutableEntryCount() const;
42
41 uint32 GetEntryCount() const; 43 uint32 GetEntryCount() const;
42 44
43 // For all accessor below, index must be < GetEntryCount(). 45 // For all read accessors below, index must be >= 1 and <=
46 // GetEntryCount(). For all mutating accessors below, index must be
47 // >= 1 and <= GetMutableEntryCount().
44 48
45 // The StringPieces returned by Get{Name,Value}At() live as long as 49 // The StringPieces returned by Get{Name,Value}At() live as long as
46 // the next call to SetMaxSize() or the Process*() functions. 50 // the next call to SetMaxSize() or the Process*() functions.
47 51
48 base::StringPiece GetNameAt(uint32 index) const; 52 base::StringPiece GetNameAt(uint32 index) const;
49 53
50 base::StringPiece GetValueAt(uint32 index) const; 54 base::StringPiece GetValueAt(uint32 index) const;
51 55
52 bool IsReferencedAt(uint32 index) const; 56 bool IsReferencedAt(uint32 index) const;
53 57
(...skipping 13 matching lines...) Expand all
67 71
68 // Sets the maximum size of the encoding text, evicting entries if 72 // Sets the maximum size of the encoding text, evicting entries if
69 // necessary. 73 // necessary.
70 void SetMaxSize(uint32 max_size); 74 void SetMaxSize(uint32 max_size);
71 75
72 // The Process*() functions below return true on success and false 76 // The Process*() functions below return true on success and false
73 // if an error was encountered. 77 // if an error was encountered.
74 78
75 // Tries to update the encoding context given an indexed header 79 // Tries to update the encoding context given an indexed header
76 // opcode for the given index as described in 3.2.1. new_index is 80 // opcode for the given index as described in 3.2.1. new_index is
77 // filled in with the index of a mutable entry, or -1 if one was not 81 // filled in with the index of a mutable entry, or 0 if one was not
78 // able to be created. removed_referenced_indices is filled in with 82 // able to be created. removed_referenced_indices is filled in with
79 // the indices of all entries removed from the reference set. 83 // the indices of all entries removed from the reference set.
80 bool ProcessIndexedHeader(uint32 index, 84 bool ProcessIndexedHeader(uint32 index,
81 int32* new_index, 85 uint32* new_index,
82 std::vector<uint32>* removed_referenced_indices); 86 std::vector<uint32>* removed_referenced_indices);
83 87
84 // Tries to update the encoding context given a literal header with 88 // Tries to update the encoding context given a literal header with
85 // incremental indexing opcode for the given name and value as 89 // incremental indexing opcode for the given name and value as
86 // described in 3.2.1. index is filled in with the index of the new 90 // described in 3.2.1. index is filled in with the index of the new
87 // entry if the header was successfully indexed, or -1 if 91 // entry if the header was successfully indexed, or 0 if
88 // not. removed_referenced_indices is filled in with the indices of 92 // not. removed_referenced_indices is filled in with the indices of
89 // all entries removed from the reference set. 93 // all entries removed from the reference set.
90 bool ProcessLiteralHeaderWithIncrementalIndexing( 94 bool ProcessLiteralHeaderWithIncrementalIndexing(
91 base::StringPiece name, 95 base::StringPiece name,
92 base::StringPiece value, 96 base::StringPiece value,
93 int32* index, 97 uint32* index,
94 std::vector<uint32>* removed_referenced_indices); 98 std::vector<uint32>* removed_referenced_indices);
95 99
96 private: 100 private:
97 HpackHeaderTable header_table_; 101 HpackHeaderTable header_table_;
98 102
99 DISALLOW_COPY_AND_ASSIGN(HpackEncodingContext); 103 DISALLOW_COPY_AND_ASSIGN(HpackEncodingContext);
100 }; 104 };
101 105
102 } // namespace net 106 } // namespace net
103 107
104 #endif // NET_SPDY_HPACK_ENCODING_CONTEXT_H_ 108 #endif // NET_SPDY_HPACK_ENCODING_CONTEXT_H_
OLDNEW
« no previous file with comments | « net/spdy/hpack_encoder.h ('k') | net/spdy/hpack_encoding_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698