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_CORE_HPACK_HPACK_HEADER_TABLE_H_ | 5 #ifndef NET_SPDY_CORE_HPACK_HPACK_HEADER_TABLE_H_ |
6 #define NET_SPDY_CORE_HPACK_HPACK_HEADER_TABLE_H_ | 6 #define NET_SPDY_CORE_HPACK_HPACK_HEADER_TABLE_H_ |
7 | 7 |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <deque> | 9 #include <deque> |
10 #include <memory> | 10 #include <memory> |
11 #include <unordered_map> | 11 #include <unordered_map> |
12 #include <unordered_set> | 12 #include <unordered_set> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "net/base/net_export.h" | |
16 #include "net/spdy/core/hpack/hpack_entry.h" | 15 #include "net/spdy/core/hpack/hpack_entry.h" |
| 16 #include "net/spdy/platform/api/spdy_export.h" |
17 #include "net/spdy/platform/api/spdy_string_piece.h" | 17 #include "net/spdy/platform/api/spdy_string_piece.h" |
18 | 18 |
19 // All section references below are to http://tools.ietf.org/html/rfc7541. | 19 // All section references below are to http://tools.ietf.org/html/rfc7541. |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 namespace test { | 23 namespace test { |
24 class HpackHeaderTablePeer; | 24 class HpackHeaderTablePeer; |
25 } // namespace test | 25 } // namespace test |
26 | 26 |
27 // A data structure for the static table (2.3.1) and the dynamic table (2.3.2). | 27 // A data structure for the static table (2.3.1) and the dynamic table (2.3.2). |
28 class NET_EXPORT_PRIVATE HpackHeaderTable { | 28 class SPDY_EXPORT_PRIVATE HpackHeaderTable { |
29 public: | 29 public: |
30 friend class test::HpackHeaderTablePeer; | 30 friend class test::HpackHeaderTablePeer; |
31 | 31 |
32 // Debug visitor my be used to extract debug/internal information | 32 // Debug visitor my be used to extract debug/internal information |
33 // about the HpackHeaderTable as it operates. | 33 // about the HpackHeaderTable as it operates. |
34 // | 34 // |
35 // Most HpackHeaderTable implementations do not need to bother with | 35 // Most HpackHeaderTable implementations do not need to bother with |
36 // this interface at all. | 36 // this interface at all. |
37 class DebugVisitorInterface { | 37 class DebugVisitorInterface { |
38 public: | 38 public: |
(...skipping 12 matching lines...) Expand all Loading... |
51 virtual void OnUseEntry(const HpackEntry& entry) = 0; | 51 virtual void OnUseEntry(const HpackEntry& entry) = 0; |
52 }; | 52 }; |
53 | 53 |
54 // HpackHeaderTable takes advantage of the deque property that references | 54 // HpackHeaderTable takes advantage of the deque property that references |
55 // remain valid, so long as insertions & deletions are at the head & tail. | 55 // remain valid, so long as insertions & deletions are at the head & tail. |
56 // If this changes (eg we start to drop entries from the middle of the table), | 56 // If this changes (eg we start to drop entries from the middle of the table), |
57 // this needs to be a std::list, in which case |*_index_| can be trivially | 57 // this needs to be a std::list, in which case |*_index_| can be trivially |
58 // extended to map to list iterators. | 58 // extended to map to list iterators. |
59 typedef std::deque<HpackEntry> EntryTable; | 59 typedef std::deque<HpackEntry> EntryTable; |
60 | 60 |
61 struct NET_EXPORT_PRIVATE EntryHasher { | 61 struct SPDY_EXPORT_PRIVATE EntryHasher { |
62 size_t operator()(const HpackEntry* entry) const; | 62 size_t operator()(const HpackEntry* entry) const; |
63 }; | 63 }; |
64 struct NET_EXPORT_PRIVATE EntriesEq { | 64 struct SPDY_EXPORT_PRIVATE EntriesEq { |
65 bool operator()(const HpackEntry* lhs, const HpackEntry* rhs) const; | 65 bool operator()(const HpackEntry* lhs, const HpackEntry* rhs) const; |
66 }; | 66 }; |
67 | 67 |
68 using UnorderedEntrySet = | 68 using UnorderedEntrySet = |
69 std::unordered_set<HpackEntry*, EntryHasher, EntriesEq>; | 69 std::unordered_set<HpackEntry*, EntryHasher, EntriesEq>; |
70 using NameToEntryMap = std:: | 70 using NameToEntryMap = std:: |
71 unordered_map<SpdyStringPiece, const HpackEntry*, base::StringPieceHash>; | 71 unordered_map<SpdyStringPiece, const HpackEntry*, base::StringPieceHash>; |
72 | 72 |
73 HpackHeaderTable(); | 73 HpackHeaderTable(); |
74 | 74 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 size_t total_insertions_; | 168 size_t total_insertions_; |
169 | 169 |
170 std::unique_ptr<DebugVisitorInterface> debug_visitor_; | 170 std::unique_ptr<DebugVisitorInterface> debug_visitor_; |
171 | 171 |
172 DISALLOW_COPY_AND_ASSIGN(HpackHeaderTable); | 172 DISALLOW_COPY_AND_ASSIGN(HpackHeaderTable); |
173 }; | 173 }; |
174 | 174 |
175 } // namespace net | 175 } // namespace net |
176 | 176 |
177 #endif // NET_SPDY_CORE_HPACK_HPACK_HEADER_TABLE_H_ | 177 #endif // NET_SPDY_CORE_HPACK_HPACK_HEADER_TABLE_H_ |
OLD | NEW |