| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_QUIC_CORE_QUIC_HEADERS_STREAM_H_ | 5 #ifndef NET_QUIC_CORE_QUIC_HEADERS_STREAM_H_ |
| 6 #define NET_QUIC_CORE_QUIC_HEADERS_STREAM_H_ | 6 #define NET_QUIC_CORE_QUIC_HEADERS_STREAM_H_ |
| 7 | 7 |
| 8 #include <cstddef> | 8 #include <cstddef> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace test { | 22 namespace test { |
| 23 class QuicHeadersStreamPeer; | 23 class QuicHeadersStreamPeer; |
| 24 } // namespace test | 24 } // namespace test |
| 25 | 25 |
| 26 // Headers in QUIC are sent as HTTP/2 HEADERS or PUSH_PROMISE frames over a | 26 // Headers in QUIC are sent as HTTP/2 HEADERS or PUSH_PROMISE frames over a |
| 27 // reserved stream with the id 3. Each endpoint (client and server) will | 27 // reserved stream with the id 3. Each endpoint (client and server) will |
| 28 // allocate an instance of QuicHeadersStream to send and receive headers. | 28 // allocate an instance of QuicHeadersStream to send and receive headers. |
| 29 class QUIC_EXPORT_PRIVATE QuicHeadersStream : public QuicStream { | 29 class QUIC_EXPORT_PRIVATE QuicHeadersStream : public QuicStream { |
| 30 public: | 30 public: |
| 31 class QUIC_EXPORT_PRIVATE HpackDebugVisitor { | |
| 32 public: | |
| 33 HpackDebugVisitor(); | |
| 34 | |
| 35 virtual ~HpackDebugVisitor(); | |
| 36 | |
| 37 // For each HPACK indexed representation processed, |elapsed| is | |
| 38 // the time since the corresponding entry was added to the dynamic | |
| 39 // table. | |
| 40 virtual void OnUseEntry(QuicTime::Delta elapsed) = 0; | |
| 41 | |
| 42 private: | |
| 43 DISALLOW_COPY_AND_ASSIGN(HpackDebugVisitor); | |
| 44 }; | |
| 45 | |
| 46 explicit QuicHeadersStream(QuicSpdySession* session); | 31 explicit QuicHeadersStream(QuicSpdySession* session); |
| 47 ~QuicHeadersStream() override; | 32 ~QuicHeadersStream() override; |
| 48 | 33 |
| 49 // Writes |headers| for |stream_id| in an HTTP/2 HEADERS frame to the peer. | |
| 50 // If |fin| is true, the fin flag will be set on the HEADERS frame. Returns | |
| 51 // the size, in bytes, of the resulting HEADERS frame. | |
| 52 virtual size_t WriteHeaders( | |
| 53 QuicStreamId stream_id, | |
| 54 SpdyHeaderBlock headers, | |
| 55 bool fin, | |
| 56 SpdyPriority priority, | |
| 57 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener); | |
| 58 | |
| 59 // Write |headers| for |promised_stream_id| on |original_stream_id| in a | |
| 60 // PUSH_PROMISE frame to peer. | |
| 61 // Return the size, in bytes, of the resulting PUSH_PROMISE frame. | |
| 62 virtual size_t WritePushPromise(QuicStreamId original_stream_id, | |
| 63 QuicStreamId promised_stream_id, | |
| 64 SpdyHeaderBlock headers); | |
| 65 | |
| 66 // For forcing HOL blocking. This encapsulates data from other | |
| 67 // streams into HTTP/2 data frames on the headers stream. | |
| 68 QuicConsumedData WritevStreamData( | |
| 69 QuicStreamId id, | |
| 70 QuicIOVector iov, | |
| 71 QuicStreamOffset offset, | |
| 72 bool fin, | |
| 73 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener); | |
| 74 | |
| 75 // QuicStream implementation | 34 // QuicStream implementation |
| 76 void OnDataAvailable() override; | 35 void OnDataAvailable() override; |
| 77 | 36 |
| 78 bool supports_push_promise() { return supports_push_promise_; } | |
| 79 | |
| 80 // Experimental: force HPACK to use static table and huffman coding | |
| 81 // only. Part of exploring improvements related to headers stream | |
| 82 // induced HOL blocking in QUIC. | |
| 83 void DisableHpackDynamicTable(); | |
| 84 | |
| 85 // Optional, enables instrumentation related to go/quic-hpack. | |
| 86 void SetHpackEncoderDebugVisitor(std::unique_ptr<HpackDebugVisitor> visitor); | |
| 87 void SetHpackDecoderDebugVisitor(std::unique_ptr<HpackDebugVisitor> visitor); | |
| 88 | |
| 89 // Sets the maximum size of the header compression table spdy_framer_ is | |
| 90 // willing to use to decode header blocks. | |
| 91 void UpdateHeaderEncoderTableSize(uint32_t value); | |
| 92 | |
| 93 // Called when SETTINGS_ENABLE_PUSH is received, only supported on | |
| 94 // server side. | |
| 95 void UpdateEnableServerPush(bool value); | |
| 96 | |
| 97 // Release underlying buffer if allowed. | 37 // Release underlying buffer if allowed. |
| 98 void MaybeReleaseSequencerBuffer(); | 38 void MaybeReleaseSequencerBuffer(); |
| 99 | 39 |
| 100 // Sends SETTINGS_MAX_HEADER_LIST_SIZE SETTINGS frame. | |
| 101 size_t SendMaxHeaderListSize(size_t value); | |
| 102 | |
| 103 // Sets how much encoded data the hpack decoder of spdy_framer_ is willing to | |
| 104 // buffer. | |
| 105 void set_max_decode_buffer_size_bytes(size_t max_decode_buffer_size_bytes) { | |
| 106 spdy_framer_.set_max_decode_buffer_size_bytes(max_decode_buffer_size_bytes); | |
| 107 } | |
| 108 | |
| 109 void set_max_uncompressed_header_bytes( | |
| 110 size_t set_max_uncompressed_header_bytes); | |
| 111 | |
| 112 private: | 40 private: |
| 113 friend class test::QuicHeadersStreamPeer; | 41 friend class test::QuicHeadersStreamPeer; |
| 114 | 42 |
| 115 class SpdyFramerVisitor; | |
| 116 | |
| 117 // The following methods are called by the SimpleVisitor. | |
| 118 | |
| 119 // Called when a HEADERS frame has been received. | |
| 120 void OnHeaders(SpdyStreamId stream_id, | |
| 121 bool has_priority, | |
| 122 SpdyPriority priority, | |
| 123 bool fin); | |
| 124 | |
| 125 // Called when a PUSH_PROMISE frame has been received. | |
| 126 void OnPushPromise(SpdyStreamId stream_id, | |
| 127 SpdyStreamId promised_stream_id, | |
| 128 bool end); | |
| 129 | |
| 130 // Called when the complete list of headers is available. | |
| 131 void OnHeaderList(const QuicHeaderList& header_list); | |
| 132 | |
| 133 // Called when the size of the compressed frame payload is available. | |
| 134 void OnCompressedFrameSize(size_t frame_len); | |
| 135 | |
| 136 // For force HOL blocking, where stream frames from all streams are | |
| 137 // plumbed through headers stream as HTTP/2 data frames. | |
| 138 // The following two return false if force_hol_blocking_ is false. | |
| 139 bool OnDataFrameHeader(QuicStreamId stream_id, size_t length, bool fin); | |
| 140 bool OnStreamFrameData(QuicStreamId stream_id, const char* data, size_t len); | |
| 141 // Helper for |WritevStreamData()|. | |
| 142 void WriteDataFrame( | |
| 143 QuicStreamId stream_id, | |
| 144 base::StringPiece data, | |
| 145 bool fin, | |
| 146 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener); | |
| 147 | |
| 148 // Returns true if the session is still connected. | 43 // Returns true if the session is still connected. |
| 149 bool IsConnected(); | 44 bool IsConnected(); |
| 150 | 45 |
| 151 QuicSpdySession* spdy_session_; | 46 QuicSpdySession* spdy_session_; |
| 152 | 47 |
| 153 // Data about the stream whose headers are being processed. | |
| 154 QuicStreamId stream_id_; | |
| 155 QuicStreamId promised_stream_id_; | |
| 156 bool fin_; | |
| 157 size_t frame_len_; | |
| 158 size_t uncompressed_frame_len_; | |
| 159 | |
| 160 bool supports_push_promise_; | |
| 161 | |
| 162 // Timestamps used to measure HOL blocking, these are recorded by | |
| 163 // the sequencer approximate to the time of arrival off the wire. | |
| 164 // |cur_max_timestamp_| tracks the most recent arrival time of | |
| 165 // frames for current (at the headers stream level) processed | |
| 166 // stream's headers, and |prev_max_timestamp_| tracks the most | |
| 167 // recent arrival time of lower numbered streams. | |
| 168 QuicTime cur_max_timestamp_; | |
| 169 QuicTime prev_max_timestamp_; | |
| 170 | |
| 171 SpdyFramer spdy_framer_; | |
| 172 std::unique_ptr<SpdyFramerVisitor> spdy_framer_visitor_; | |
| 173 | |
| 174 DISALLOW_COPY_AND_ASSIGN(QuicHeadersStream); | 48 DISALLOW_COPY_AND_ASSIGN(QuicHeadersStream); |
| 175 }; | 49 }; |
| 176 | 50 |
| 177 } // namespace net | 51 } // namespace net |
| 178 | 52 |
| 179 #endif // NET_QUIC_CORE_QUIC_HEADERS_STREAM_H_ | 53 #endif // NET_QUIC_CORE_QUIC_HEADERS_STREAM_H_ |
| OLD | NEW |