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

Side by Side Diff: net/quic/quic_headers_stream.h

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 4 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/quic/quic_header_list_test.cc ('k') | net/quic/quic_headers_stream.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 2013 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_QUIC_QUIC_HEADERS_STREAM_H_
6 #define NET_QUIC_QUIC_HEADERS_STREAM_H_
7
8 #include <stddef.h>
9
10 #include <memory>
11
12 #include "base/macros.h"
13 #include "net/base/net_export.h"
14 #include "net/quic/quic_header_list.h"
15 #include "net/quic/quic_protocol.h"
16 #include "net/quic/reliable_quic_stream.h"
17 #include "net/spdy/spdy_framer.h"
18
19 namespace net {
20
21 class QuicSpdySession;
22
23 namespace test {
24 class QuicHeadersStreamPeer;
25 } // namespace test
26
27 // Headers in QUIC are sent as HTTP/2 HEADERS or PUSH_PROMISE frames
28 // over a reserved reliable stream with the id 3. Each endpoint
29 // (client and server) will allocate an instance of QuicHeadersStream
30 // to send and receive headers.
31 class NET_EXPORT_PRIVATE QuicHeadersStream : public ReliableQuicStream {
32 public:
33 class NET_EXPORT_PRIVATE HpackDebugVisitor {
34 public:
35 HpackDebugVisitor();
36
37 virtual ~HpackDebugVisitor();
38
39 // For each HPACK indexed representation processed, |elapsed| is
40 // the time since the corresponding entry was added to the dynamic
41 // table.
42 virtual void OnUseEntry(QuicTime::Delta elapsed) = 0;
43
44 private:
45 DISALLOW_COPY_AND_ASSIGN(HpackDebugVisitor);
46 };
47
48 explicit QuicHeadersStream(QuicSpdySession* session);
49 ~QuicHeadersStream() override;
50
51 // Writes |headers| for |stream_id| in an HTTP/2 HEADERS frame to the peer.
52 // If |fin| is true, the fin flag will be set on the HEADERS frame. Returns
53 // the size, in bytes, of the resulting HEADERS frame.
54 virtual size_t WriteHeaders(QuicStreamId stream_id,
55 SpdyHeaderBlock headers,
56 bool fin,
57 SpdyPriority priority,
58 QuicAckListenerInterface* ack_listener);
59
60 // Write |headers| for |promised_stream_id| on |original_stream_id| in a
61 // PUSH_PROMISE frame to peer.
62 // Return the size, in bytes, of the resulting PUSH_PROMISE frame.
63 virtual size_t WritePushPromise(QuicStreamId original_stream_id,
64 QuicStreamId promised_stream_id,
65 SpdyHeaderBlock headers,
66 QuicAckListenerInterface* ack_listener);
67
68 // For forcing HOL blocking. This encapsulates data from other
69 // streams into HTTP/2 data frames on the headers stream.
70 QuicConsumedData WritevStreamData(
71 QuicStreamId id,
72 QuicIOVector iov,
73 QuicStreamOffset offset,
74 bool fin,
75 QuicAckListenerInterface* ack_notifier_delegate);
76
77 // ReliableQuicStream implementation
78 void OnDataAvailable() override;
79
80 bool supports_push_promise() { return supports_push_promise_; }
81
82 // Experimental: force HPACK to use static table and huffman coding
83 // only. Part of exploring improvements related to headers stream
84 // induced HOL blocking in QUIC.
85 void DisableHpackDynamicTable();
86
87 // Optional, enables instrumentation related to go/quic-hpack.
88 void SetHpackEncoderDebugVisitor(std::unique_ptr<HpackDebugVisitor> visitor);
89 void SetHpackDecoderDebugVisitor(std::unique_ptr<HpackDebugVisitor> visitor);
90
91 // Sets the maximum size of the header compression table spdy_framer_ is
92 // willing to use to decode header blocks.
93 void UpdateHeaderEncoderTableSize(uint32_t value);
94
95 // Sets how much encoded data the hpack decoder of spdy_framer_ is willing to
96 // buffer.
97 void set_max_decode_buffer_size_bytes(size_t max_decode_buffer_size_bytes) {
98 spdy_framer_.set_max_decode_buffer_size_bytes(max_decode_buffer_size_bytes);
99 }
100
101 private:
102 friend class test::QuicHeadersStreamPeer;
103
104 class SpdyFramerVisitor;
105
106 // The following methods are called by the SimpleVisitor.
107
108 // Called when a HEADERS frame has been received.
109 void OnHeaders(SpdyStreamId stream_id,
110 bool has_priority,
111 SpdyPriority priority,
112 bool fin);
113
114 // Called when a PUSH_PROMISE frame has been received.
115 void OnPushPromise(SpdyStreamId stream_id,
116 SpdyStreamId promised_stream_id,
117 bool end);
118
119 // Called when a chunk of header data is available. This is called
120 // after OnHeaders.
121 // |stream_id| The stream receiving the header data.
122 // |header_data| A buffer containing the header data chunk received.
123 // |len| The length of the header data buffer. A length of zero indicates
124 // that the header data block has been completely sent.
125 void OnControlFrameHeaderData(SpdyStreamId stream_id,
126 const char* header_data,
127 size_t len);
128
129 // Called when the complete list of headers is available.
130 void OnHeaderList(const QuicHeaderList& header_list);
131
132 // Called when the size of the compressed frame payload is available.
133 void OnCompressedFrameSize(size_t frame_len);
134
135 // For force HOL blocking, where stream frames from all streams are
136 // plumbed through headers stream as HTTP/2 data frames. Return false
137 // if force_hol_blocking_ is false;
138 bool OnDataFrameHeader(QuicStreamId stream_id, size_t length, bool fin);
139 bool OnStreamFrameData(QuicStreamId stream_id, const char* data, size_t len);
140
141 // Returns true if the session is still connected.
142 bool IsConnected();
143
144 QuicSpdySession* spdy_session_;
145
146 // Data about the stream whose headers are being processed.
147 QuicStreamId stream_id_;
148 QuicStreamId promised_stream_id_;
149 bool fin_;
150 size_t frame_len_;
151 size_t uncompressed_frame_len_;
152
153 // Helper variables that cache the corresponding feature flag.
154 bool measure_headers_hol_blocking_time_;
155 bool supports_push_promise_;
156
157 // Timestamps used to measure HOL blocking, these are recorded by
158 // the sequencer approximate to the time of arrival off the wire.
159 // |cur_max_timestamp_| tracks the most recent arrival time of
160 // frames for current (at the headers stream level) processed
161 // stream's headers, and |prev_max_timestamp_| tracks the most
162 // recent arrival time of lower numbered streams.
163 QuicTime cur_max_timestamp_;
164 QuicTime prev_max_timestamp_;
165
166 SpdyFramer spdy_framer_;
167 std::unique_ptr<SpdyFramerVisitor> spdy_framer_visitor_;
168
169 // Either empty, or contains the complete list of headers.
170 QuicHeaderList header_list_;
171
172 DISALLOW_COPY_AND_ASSIGN(QuicHeadersStream);
173 };
174
175 } // namespace net
176
177 #endif // NET_QUIC_QUIC_HEADERS_STREAM_H_
OLDNEW
« no previous file with comments | « net/quic/quic_header_list_test.cc ('k') | net/quic/quic_headers_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698