blob: f354a120ca5f71f72e7725d8c93f91f99b853a97 [file] [log] [blame]
QUICHE team82dee2f2019-01-18 12:35:12 -05001// 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 "net/third_party/quiche/src/spdy/core/hpack/hpack_header_table.h"
9#include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h"
10
11namespace spdy {
12
13struct HpackStaticEntry;
14
15// HpackStaticTable provides |static_entries_| and |static_index_| for HPACK
16// encoding and decoding contexts. Once initialized, an instance is read only
17// and may be accessed only through its const interface. Such an instance may
18// be shared accross multiple HPACK contexts.
19class SPDY_EXPORT_PRIVATE HpackStaticTable {
20 public:
21 HpackStaticTable();
22 ~HpackStaticTable();
23
24 // Prepares HpackStaticTable by filling up static_entries_ and static_index_
25 // from an array of struct HpackStaticEntry. Must be called exactly once.
26 void Initialize(const HpackStaticEntry* static_entry_table,
27 size_t static_entry_count);
28
29 // Returns whether Initialize() has been called.
30 bool IsInitialized() const;
31
32 // Accessors.
33 const HpackHeaderTable::EntryTable& GetStaticEntries() const {
34 return static_entries_;
35 }
36 const HpackHeaderTable::UnorderedEntrySet& GetStaticIndex() const {
37 return static_index_;
38 }
39 const HpackHeaderTable::NameToEntryMap& GetStaticNameIndex() const {
40 return static_name_index_;
41 }
42
43 // Returns the estimate of dynamically allocated memory in bytes.
44 size_t EstimateMemoryUsage() const;
45
46 private:
47 HpackHeaderTable::EntryTable static_entries_;
48 HpackHeaderTable::UnorderedEntrySet static_index_;
49 HpackHeaderTable::NameToEntryMap static_name_index_;
50};
51
52} // namespace spdy
53
54#endif // QUICHE_SPDY_CORE_HPACK_HPACK_STATIC_TABLE_H_