Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: net/spdy/hpack/hpack_decoder3.h

Issue 2832973003: Split net/spdy into core and chromium subdirectories. (Closed)
Patch Set: Fix some more build rules. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/hpack/hpack_decoder.cc ('k') | net/spdy/hpack/hpack_decoder3.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 NET_SPDY_HPACK_HPACK_DECODER3_H_
6 #define NET_SPDY_HPACK_HPACK_DECODER3_H_
7
8 // HpackDecoder3 implements HpackDecoderInterface, using Http2HpackDecoder to
9 // decode HPACK blocks into HTTP/2 header lists as outlined in
10 // http://tools.ietf.org/html/rfc7541.
11
12 #include <stddef.h>
13
14 #include <memory>
15
16 #include "base/macros.h"
17 #include "net/base/net_export.h"
18 #include "net/http2/hpack/decoder/hpack_decoder_listener.h"
19 #include "net/http2/hpack/decoder/http2_hpack_decoder.h"
20 #include "net/http2/hpack/hpack_string.h"
21 #include "net/http2/hpack/http2_hpack_constants.h"
22 #include "net/spdy/hpack/hpack_decoder_interface.h"
23 #include "net/spdy/hpack/hpack_header_table.h"
24 #include "net/spdy/platform/api/spdy_string_piece.h"
25 #include "net/spdy/spdy_header_block.h"
26 #include "net/spdy/spdy_headers_handler_interface.h"
27
28 namespace net {
29 namespace test {
30 class HpackDecoder3Peer;
31 } // namespace test
32
33 class NET_EXPORT_PRIVATE HpackDecoder3 : public HpackDecoderInterface {
34 public:
35 friend test::HpackDecoder3Peer;
36 HpackDecoder3();
37 ~HpackDecoder3() override;
38
39 // Override the HpackDecoderInterface methods:
40
41 void ApplyHeaderTableSizeSetting(size_t size_setting) override;
42 void HandleControlFrameHeadersStart(
43 SpdyHeadersHandlerInterface* handler) override;
44 bool HandleControlFrameHeadersData(const char* headers_data,
45 size_t headers_data_length) override;
46 bool HandleControlFrameHeadersComplete(size_t* compressed_len) override;
47 const SpdyHeaderBlock& decoded_block() const override;
48 void SetHeaderTableDebugVisitor(
49 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor)
50 override;
51 void set_max_decode_buffer_size_bytes(
52 size_t max_decode_buffer_size_bytes) override;
53 size_t EstimateMemoryUsage() const override;
54
55 private:
56 class NET_EXPORT_PRIVATE ListenerAdapter
57 : public HpackDecoderListener,
58 public HpackDecoderTablesDebugListener {
59 public:
60 ListenerAdapter();
61 ~ListenerAdapter() override;
62
63 // If a SpdyHeadersHandlerInterface is provided, the decoder will emit
64 // headers to it rather than accumulating them in a SpdyHeaderBlock.
65 // Does not take ownership of the handler, but does use the pointer until
66 // the current HPACK block is completely decoded.
67 void set_handler(SpdyHeadersHandlerInterface* handler);
68 const SpdyHeaderBlock& decoded_block() const { return decoded_block_; }
69
70 void SetHeaderTableDebugVisitor(
71 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor);
72
73 // Override the HpackDecoderListener methods:
74 void OnHeaderListStart() override;
75 void OnHeader(HpackEntryType entry_type,
76 const HpackString& name,
77 const HpackString& value) override;
78 void OnHeaderListEnd() override;
79 void OnHeaderErrorDetected(SpdyStringPiece error_message) override;
80
81 // Override the HpackDecoderTablesDebugListener methods:
82 int64_t OnEntryInserted(const HpackStringPair& entry,
83 size_t insert_count) override;
84 void OnUseEntry(const HpackStringPair& entry,
85 size_t insert_count,
86 int64_t insert_time) override;
87
88 void AddToTotalHpackBytes(size_t delta) { total_hpack_bytes_ += delta; }
89 size_t total_hpack_bytes() const { return total_hpack_bytes_; }
90
91 private:
92 // If the caller doesn't provide a handler, the header list is stored in
93 // this SpdyHeaderBlock.
94 SpdyHeaderBlock decoded_block_;
95
96 // If non-NULL, handles decoded headers. Not owned.
97 SpdyHeadersHandlerInterface* handler_;
98
99 // Total bytes that have been received as input (i.e. HPACK encoded)
100 // in the current HPACK block.
101 size_t total_hpack_bytes_;
102
103 // Total bytes of the name and value strings in the current HPACK block.
104 size_t total_uncompressed_bytes_;
105
106 // visitor_ is used by a QUIC experiment regarding HPACK; remove
107 // when the experiment is done.
108 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor_;
109 };
110
111 // Converts calls to HpackDecoderListener into calls to
112 // SpdyHeadersHandlerInterface.
113 ListenerAdapter listener_adapter_;
114
115 // The actual decoder.
116 Http2HpackDecoder hpack_decoder_;
117
118 // How much encoded data this decoder is willing to buffer.
119 size_t max_decode_buffer_size_bytes_;
120
121 // Flag to keep track of having seen the header block start. Needed at the
122 // moment because HandleControlFrameHeadersStart won't be called if a handler
123 // is not being provided by the caller.
124 bool header_block_started_;
125
126 DISALLOW_COPY_AND_ASSIGN(HpackDecoder3);
127 };
128
129 } // namespace net
130
131 #endif // NET_SPDY_HPACK_HPACK_DECODER3_H_
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_decoder.cc ('k') | net/spdy/hpack/hpack_decoder3.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698