| 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_HEADER_TABLE_H_ | 5 #ifndef NET_SPDY_HPACK_HEADER_TABLE_H_ |
| 6 #define NET_SPDY_HPACK_HEADER_TABLE_H_ | 6 #define NET_SPDY_HPACK_HEADER_TABLE_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 "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
| 15 #include "net/spdy/hpack_entry.h" | 15 #include "net/spdy/hpack_entry.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 // All section references below are to | 19 // All section references below are to |
| 20 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-04 | 20 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-05 |
| 21 // . | 21 // . |
| 22 | 22 |
| 23 // A data structure for both the header table (described in 3.1.2) and | 23 // A data structure for both the header table (described in 3.1.2) and |
| 24 // the reference set (3.1.3). This structure also keeps track of how | 24 // the reference set (3.1.3). This structure also keeps track of how |
| 25 // many times a header has been 'touched', which is useful for both | 25 // many times a header has been 'touched', which is useful for both |
| 26 // encoding and decoding. | 26 // encoding and decoding. |
| 27 class NET_EXPORT_PRIVATE HpackHeaderTable { | 27 class NET_EXPORT_PRIVATE HpackHeaderTable { |
| 28 public: | 28 public: |
| 29 HpackHeaderTable(); | 29 HpackHeaderTable(); |
| 30 | 30 |
| 31 ~HpackHeaderTable(); | 31 ~HpackHeaderTable(); |
| 32 | 32 |
| 33 uint32 size() const { return size_; } | 33 uint32 size() const { return size_; } |
| 34 uint32 max_size() const { return max_size_; } | 34 uint32 max_size() const { return max_size_; } |
| 35 | 35 |
| 36 // Returns the total number of entries. | 36 // Returns the total number of entries. |
| 37 uint32 GetEntryCount() const; | 37 uint32 GetEntryCount() const; |
| 38 | 38 |
| 39 // The given index must be >= 0 and < GetEntryCount(). | 39 // The given index must be >= 1 and <= GetEntryCount(). |
| 40 const HpackEntry& GetEntry(uint32 index) const; | 40 const HpackEntry& GetEntry(uint32 index) const; |
| 41 | 41 |
| 42 // The given index must be >= 0 and < GetEntryCount(). | 42 // The given index must be >= 1 and <= GetEntryCount(). |
| 43 HpackEntry* GetMutableEntry(uint32 index); | 43 HpackEntry* GetMutableEntry(uint32 index); |
| 44 | 44 |
| 45 // Sets the maximum size of the header table, evicting entries if | 45 // Sets the maximum size of the header table, evicting entries if |
| 46 // necessary as described in 3.3.2. | 46 // necessary as described in 3.3.2. |
| 47 void SetMaxSize(uint32 max_size); | 47 void SetMaxSize(uint32 max_size); |
| 48 | 48 |
| 49 // The given entry must not be one from the header table, since it | 49 // The given entry must not be one from the header table, since it |
| 50 // may get evicted. Tries to add the given entry to the header | 50 // may get evicted. Tries to add the given entry to the header |
| 51 // table, evicting entries if necessary as described in 3.3.3. index | 51 // table, evicting entries if necessary as described in 3.3.3. index |
| 52 // will be filled in with the index of the added entry, or -1 if the | 52 // will be filled in with the index of the added entry, or 0 if the |
| 53 // entry could not be added. removed_referenced_indices will be | 53 // entry could not be added. removed_referenced_indices will be |
| 54 // filled in with the indices of any removed entries that were in | 54 // filled in with the indices of any removed entries that were in |
| 55 // the reference set. | 55 // the reference set. |
| 56 void TryAddEntry(const HpackEntry& entry, | 56 void TryAddEntry(const HpackEntry& entry, |
| 57 int32* index, | 57 uint32* index, |
| 58 std::vector<uint32>* removed_referenced_indices); | 58 std::vector<uint32>* removed_referenced_indices); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 std::deque<HpackEntry> entries_; | 61 std::deque<HpackEntry> entries_; |
| 62 uint32 size_; | 62 uint32 size_; |
| 63 uint32 max_size_; | 63 uint32 max_size_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(HpackHeaderTable); | 65 DISALLOW_COPY_AND_ASSIGN(HpackHeaderTable); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace net | 68 } // namespace net |
| 69 | 69 |
| 70 #endif // NET_SPDY_HPACK_HEADER_TABLE_H_ | 70 #endif // NET_SPDY_HPACK_HEADER_TABLE_H_ |
| OLD | NEW |