• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 QUICHE_SPDY_CORE_HPACK_HPACK_STATIC_TABLE_H_
6 #define QUICHE_SPDY_CORE_HPACK_HPACK_STATIC_TABLE_H_
7 
8 #include "quiche/common/platform/api/quiche_export.h"
9 #include "quiche/spdy/core/hpack/hpack_header_table.h"
10 
11 namespace spdy {
12 
13 struct HpackStaticEntry;
14 
15 // Number of entries in the HPACK static table.
16 constexpr size_t kStaticTableSize = 61;
17 
18 // HpackStaticTable provides |static_entries_| and |static_index_| for HPACK
19 // encoding and decoding contexts.  Once initialized, an instance is read only
20 // and may be accessed only through its const interface.  Such an instance may
21 // be shared accross multiple HPACK contexts.
22 class QUICHE_EXPORT HpackStaticTable {
23  public:
24   HpackStaticTable();
25   ~HpackStaticTable();
26 
27   // Prepares HpackStaticTable by filling up static_entries_ and static_index_
28   // from an array of struct HpackStaticEntry.  Must be called exactly once.
29   void Initialize(const HpackStaticEntry* static_entry_table,
30                   size_t static_entry_count);
31 
32   // Returns whether Initialize() has been called.
33   bool IsInitialized() const;
34 
35   // Accessors.
GetStaticEntries()36   const HpackHeaderTable::StaticEntryTable& GetStaticEntries() const {
37     return static_entries_;
38   }
GetStaticIndex()39   const HpackHeaderTable::NameValueToEntryMap& GetStaticIndex() const {
40     return static_index_;
41   }
GetStaticNameIndex()42   const HpackHeaderTable::NameToEntryMap& GetStaticNameIndex() const {
43     return static_name_index_;
44   }
45 
46  private:
47   HpackHeaderTable::StaticEntryTable static_entries_;
48   // The following two members have string_views that point to strings stored in
49   // |static_entries_|.
50   HpackHeaderTable::NameValueToEntryMap static_index_;
51   HpackHeaderTable::NameToEntryMap static_name_index_;
52 };
53 
54 }  // namespace spdy
55 
56 #endif  // QUICHE_SPDY_CORE_HPACK_HPACK_STATIC_TABLE_H_
57