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

Side by Side Diff: net/spdy/hpack/hpack_entry.h

Issue 2832973003: Split net/spdy into core and chromium subdirectories. (Closed)
Patch Set: Fix some more build rules. Created 3 years, 8 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/spdy/hpack/hpack_encoder_test.cc ('k') | net/spdy/hpack/hpack_entry.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 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.
4
5 #ifndef NET_SPDY_HPACK_HPACK_ENTRY_H_
6 #define NET_SPDY_HPACK_HPACK_ENTRY_H_
7
8 #include <stddef.h>
9
10 #include "base/macros.h"
11 #include "net/base/net_export.h"
12 #include "net/spdy/platform/api/spdy_string.h"
13 #include "net/spdy/platform/api/spdy_string_piece.h"
14
15 // All section references below are to
16 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08
17
18 namespace net {
19
20 // A structure for an entry in the static table (3.3.1)
21 // and the header table (3.3.2).
22 class NET_EXPORT_PRIVATE HpackEntry {
23 public:
24 // The constant amount added to name().size() and value().size() to
25 // get the size of an HpackEntry as defined in 5.1.
26 static const size_t kSizeOverhead;
27
28 // Creates an entry. Preconditions:
29 // - |is_static| captures whether this entry is a member of the static
30 // or dynamic header table.
31 // - |insertion_index| is this entry's index in the total set of entries ever
32 // inserted into the header table (including static entries).
33 //
34 // The combination of |is_static| and |insertion_index| allows an
35 // HpackEntryTable to determine the index of an HpackEntry in O(1) time.
36 // Copies |name| and |value|.
37 HpackEntry(SpdyStringPiece name,
38 SpdyStringPiece value,
39 bool is_static,
40 size_t insertion_index);
41
42 // Create a 'lookup' entry (only) suitable for querying a HpackEntrySet. The
43 // instance InsertionIndex() always returns 0 and IsLookup() returns true.
44 // The memory backing |name| and |value| must outlive this object.
45 HpackEntry(SpdyStringPiece name, SpdyStringPiece value);
46
47 HpackEntry(const HpackEntry& other);
48 HpackEntry& operator=(const HpackEntry& other);
49
50 // Creates an entry with empty name and value. Only defined so that
51 // entries can be stored in STL containers.
52 HpackEntry();
53
54 ~HpackEntry();
55
56 SpdyStringPiece name() const { return name_ref_; }
57 SpdyStringPiece value() const { return value_ref_; }
58
59 // Returns whether this entry is a member of the static (as opposed to
60 // dynamic) table.
61 bool IsStatic() const { return type_ == STATIC; }
62
63 // Returns whether this entry is a lookup-only entry.
64 bool IsLookup() const { return type_ == LOOKUP; }
65
66 // Used to compute the entry's index in the header table.
67 size_t InsertionIndex() const { return insertion_index_; }
68
69 // Returns the size of an entry as defined in 5.1.
70 static size_t Size(SpdyStringPiece name, SpdyStringPiece value);
71 size_t Size() const;
72
73 SpdyString GetDebugString() const;
74
75 int64_t time_added() const { return time_added_; }
76 void set_time_added(int64_t now) { time_added_ = now; }
77
78 // Returns the estimate of dynamically allocated memory in bytes.
79 size_t EstimateMemoryUsage() const;
80
81 private:
82 enum EntryType {
83 LOOKUP,
84 DYNAMIC,
85 STATIC,
86 };
87
88 // These members are not used for LOOKUP entries.
89 SpdyString name_;
90 SpdyString value_;
91
92 // These members are always valid. For DYNAMIC and STATIC entries, they
93 // always point to |name_| and |value_|.
94 SpdyStringPiece name_ref_;
95 SpdyStringPiece value_ref_;
96
97 // The entry's index in the total set of entries ever inserted into the header
98 // table.
99 size_t insertion_index_;
100
101 EntryType type_;
102
103 // For HpackHeaderTable::DebugVisitorInterface
104 int64_t time_added_;
105 };
106
107 } // namespace net
108
109 #endif // NET_SPDY_HPACK_HPACK_ENTRY_H_
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_encoder_test.cc ('k') | net/spdy/hpack/hpack_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698