| OLD | NEW |
| 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_HPACK_ENTRY_H_ | 5 #ifndef NET_SPDY_HPACK_HPACK_ENTRY_H_ |
| 6 #define NET_SPDY_HPACK_HPACK_ENTRY_H_ | 6 #define NET_SPDY_HPACK_HPACK_ENTRY_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/macros.h" | 10 #include "base/macros.h" |
| 13 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 #include "net/spdy/platform/api/spdy_string.h" |
| 14 #include "net/spdy/platform/api/spdy_string_piece.h" | 13 #include "net/spdy/platform/api/spdy_string_piece.h" |
| 15 | 14 |
| 16 // All section references below are to | 15 // All section references below are to |
| 17 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 | 16 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 |
| 18 | 17 |
| 19 namespace net { | 18 namespace net { |
| 20 | 19 |
| 21 // A structure for an entry in the static table (3.3.1) | 20 // A structure for an entry in the static table (3.3.1) |
| 22 // and the header table (3.3.2). | 21 // and the header table (3.3.2). |
| 23 class NET_EXPORT_PRIVATE HpackEntry { | 22 class NET_EXPORT_PRIVATE HpackEntry { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Returns whether this entry is a lookup-only entry. | 63 // Returns whether this entry is a lookup-only entry. |
| 65 bool IsLookup() const { return type_ == LOOKUP; } | 64 bool IsLookup() const { return type_ == LOOKUP; } |
| 66 | 65 |
| 67 // Used to compute the entry's index in the header table. | 66 // Used to compute the entry's index in the header table. |
| 68 size_t InsertionIndex() const { return insertion_index_; } | 67 size_t InsertionIndex() const { return insertion_index_; } |
| 69 | 68 |
| 70 // Returns the size of an entry as defined in 5.1. | 69 // Returns the size of an entry as defined in 5.1. |
| 71 static size_t Size(SpdyStringPiece name, SpdyStringPiece value); | 70 static size_t Size(SpdyStringPiece name, SpdyStringPiece value); |
| 72 size_t Size() const; | 71 size_t Size() const; |
| 73 | 72 |
| 74 std::string GetDebugString() const; | 73 SpdyString GetDebugString() const; |
| 75 | 74 |
| 76 int64_t time_added() const { return time_added_; } | 75 int64_t time_added() const { return time_added_; } |
| 77 void set_time_added(int64_t now) { time_added_ = now; } | 76 void set_time_added(int64_t now) { time_added_ = now; } |
| 78 | 77 |
| 79 // Returns the estimate of dynamically allocated memory in bytes. | 78 // Returns the estimate of dynamically allocated memory in bytes. |
| 80 size_t EstimateMemoryUsage() const; | 79 size_t EstimateMemoryUsage() const; |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 enum EntryType { | 82 enum EntryType { |
| 84 LOOKUP, | 83 LOOKUP, |
| 85 DYNAMIC, | 84 DYNAMIC, |
| 86 STATIC, | 85 STATIC, |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 // These members are not used for LOOKUP entries. | 88 // These members are not used for LOOKUP entries. |
| 90 std::string name_; | 89 SpdyString name_; |
| 91 std::string value_; | 90 SpdyString value_; |
| 92 | 91 |
| 93 // These members are always valid. For DYNAMIC and STATIC entries, they | 92 // These members are always valid. For DYNAMIC and STATIC entries, they |
| 94 // always point to |name_| and |value_|. | 93 // always point to |name_| and |value_|. |
| 95 SpdyStringPiece name_ref_; | 94 SpdyStringPiece name_ref_; |
| 96 SpdyStringPiece value_ref_; | 95 SpdyStringPiece value_ref_; |
| 97 | 96 |
| 98 // The entry's index in the total set of entries ever inserted into the header | 97 // The entry's index in the total set of entries ever inserted into the header |
| 99 // table. | 98 // table. |
| 100 size_t insertion_index_; | 99 size_t insertion_index_; |
| 101 | 100 |
| 102 EntryType type_; | 101 EntryType type_; |
| 103 | 102 |
| 104 // For HpackHeaderTable::DebugVisitorInterface | 103 // For HpackHeaderTable::DebugVisitorInterface |
| 105 int64_t time_added_; | 104 int64_t time_added_; |
| 106 }; | 105 }; |
| 107 | 106 |
| 108 } // namespace net | 107 } // namespace net |
| 109 | 108 |
| 110 #endif // NET_SPDY_HPACK_HPACK_ENTRY_H_ | 109 #endif // NET_SPDY_HPACK_HPACK_ENTRY_H_ |
| OLD | NEW |