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 #include "net/quic/quic_headers_stream.h" | 5 #include "net/quic/quic_headers_stream.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "net/quic/quic_bug_tracker.h" | 10 #include "net/quic/quic_bug_tracker.h" |
11 #include "net/quic/quic_flags.h" | 11 #include "net/quic/quic_flags.h" |
12 #include "net/quic/quic_headers_stream.h" | 12 #include "net/quic/quic_headers_stream.h" |
13 #include "net/quic/quic_header_list.h" | |
13 #include "net/quic/quic_spdy_session.h" | 14 #include "net/quic/quic_spdy_session.h" |
14 #include "net/quic/quic_time.h" | 15 #include "net/quic/quic_time.h" |
15 | 16 |
16 using base::StringPiece; | 17 using base::StringPiece; |
17 using net::HTTP2; | 18 using net::HTTP2; |
18 using net::SpdyFrameType; | 19 using net::SpdyFrameType; |
19 using std::string; | 20 using std::string; |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 | 23 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 void OnStreamEnd(SpdyStreamId stream_id) override { | 69 void OnStreamEnd(SpdyStreamId stream_id) override { |
69 // The framer invokes OnStreamEnd after processing a SYN_STREAM | 70 // The framer invokes OnStreamEnd after processing a SYN_STREAM |
70 // or SYN_REPLY frame that had the fin bit set. | 71 // or SYN_REPLY frame that had the fin bit set. |
71 } | 72 } |
72 | 73 |
73 void OnStreamPadding(SpdyStreamId stream_id, size_t len) override { | 74 void OnStreamPadding(SpdyStreamId stream_id, size_t len) override { |
74 CloseConnection("SPDY frame padding received."); | 75 CloseConnection("SPDY frame padding received."); |
75 } | 76 } |
76 | 77 |
77 SpdyHeadersHandlerInterface* OnHeaderFrameStart( | 78 SpdyHeadersHandlerInterface* OnHeaderFrameStart( |
78 SpdyStreamId stream_id) override { | 79 SpdyStreamId /* stream_id */) override { |
79 LOG(FATAL); | 80 return &header_list_; |
80 return nullptr; | |
81 } | 81 } |
82 | 82 |
83 void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override { | 83 void OnHeaderFrameEnd(SpdyStreamId /* stream_id */, |
84 LOG(FATAL); | 84 bool end_headers) override { |
85 if (end_headers) { | |
86 if (stream_->IsConnected()) { | |
87 stream_->OnHeaderList(header_list_); | |
88 } | |
89 header_list_.Clear(); | |
90 } | |
85 } | 91 } |
86 | 92 |
87 void OnError(SpdyFramer* framer) override { | 93 void OnError(SpdyFramer* framer) override { |
88 CloseConnection(base::StringPrintf( | 94 CloseConnection(base::StringPrintf( |
89 "SPDY framing error: %s", | 95 "SPDY framing error: %s", |
90 SpdyFramer::ErrorCodeToString(framer->error_code()))); | 96 SpdyFramer::ErrorCodeToString(framer->error_code()))); |
91 } | 97 } |
92 | 98 |
93 void OnDataFrameHeader(SpdyStreamId stream_id, | 99 void OnDataFrameHeader(SpdyStreamId stream_id, |
94 size_t length, | 100 size_t length, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 private: | 183 private: |
178 void CloseConnection(const string& details) { | 184 void CloseConnection(const string& details) { |
179 if (stream_->IsConnected()) { | 185 if (stream_->IsConnected()) { |
180 stream_->CloseConnectionWithDetails(QUIC_INVALID_HEADERS_STREAM_DATA, | 186 stream_->CloseConnectionWithDetails(QUIC_INVALID_HEADERS_STREAM_DATA, |
181 details); | 187 details); |
182 } | 188 } |
183 } | 189 } |
184 | 190 |
185 private: | 191 private: |
186 QuicHeadersStream* stream_; | 192 QuicHeadersStream* stream_; |
193 QuicHeaderList header_list_; | |
187 | 194 |
188 DISALLOW_COPY_AND_ASSIGN(SpdyFramerVisitor); | 195 DISALLOW_COPY_AND_ASSIGN(SpdyFramerVisitor); |
189 }; | 196 }; |
190 | 197 |
191 QuicHeadersStream::QuicHeadersStream(QuicSpdySession* session) | 198 QuicHeadersStream::QuicHeadersStream(QuicSpdySession* session) |
192 : ReliableQuicStream(kHeadersStreamId, session), | 199 : ReliableQuicStream(kHeadersStreamId, session), |
193 spdy_session_(session), | 200 spdy_session_(session), |
194 stream_id_(kInvalidStreamId), | 201 stream_id_(kInvalidStreamId), |
195 promised_stream_id_(kInvalidStreamId), | 202 promised_stream_id_(kInvalidStreamId), |
196 fin_(false), | 203 fin_(false), |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 } else { | 356 } else { |
350 if (promised_stream_id_ == kInvalidStreamId) { | 357 if (promised_stream_id_ == kInvalidStreamId) { |
351 spdy_session_->OnStreamHeaders(stream_id_, StringPiece(header_data, len)); | 358 spdy_session_->OnStreamHeaders(stream_id_, StringPiece(header_data, len)); |
352 } else { | 359 } else { |
353 spdy_session_->OnPromiseHeaders(stream_id_, | 360 spdy_session_->OnPromiseHeaders(stream_id_, |
354 StringPiece(header_data, len)); | 361 StringPiece(header_data, len)); |
355 } | 362 } |
356 } | 363 } |
357 } | 364 } |
358 | 365 |
366 void QuicHeadersStream::OnHeaderList(const QuicHeaderList& header_list) { | |
367 if (measure_headers_hol_blocking_time_) { | |
368 if (prev_max_timestamp_ > cur_max_timestamp_) { | |
369 // prev_max_timestamp_ > cur_max_timestamp_ implies that | |
370 // headers from lower numbered streams actually came off the | |
371 // wire after headers for the current stream, hence there was | |
372 // HOL blocking. | |
373 QuicTime::Delta delta = prev_max_timestamp_.Subtract(cur_max_timestamp_); | |
374 DVLOG(1) << "stream " << stream_id_ | |
375 << ": Net.QuicSession.HeadersHOLBlockedTime " | |
ramant (doing other things)
2016/04/11 18:11:57
nit: indentation for lines 375-376.
Zhongyi Shi
2016/04/11 18:27:31
it's already fixed in Final.
| |
376 << delta.ToMilliseconds(); | |
377 spdy_session_->OnHeadersHeadOfLineBlocking(delta); | |
378 } | |
379 prev_max_timestamp_ = std::max(prev_max_timestamp_, cur_max_timestamp_); | |
380 cur_max_timestamp_ = QuicTime::Zero(); | |
381 } | |
382 if (promised_stream_id_ == kInvalidStreamId) { | |
383 spdy_session_->OnStreamHeaderList(stream_id_, fin_, frame_len_, | |
384 header_list); | |
385 } else { | |
386 spdy_session_->OnPromiseHeaderList(stream_id_, promised_stream_id_, | |
387 frame_len_, header_list); | |
388 } | |
389 // Reset state for the next frame. | |
390 promised_stream_id_ = kInvalidStreamId; | |
391 stream_id_ = kInvalidStreamId; | |
392 fin_ = false; | |
393 frame_len_ = 0; | |
394 } | |
395 | |
359 void QuicHeadersStream::OnCompressedFrameSize(size_t frame_len) { | 396 void QuicHeadersStream::OnCompressedFrameSize(size_t frame_len) { |
360 frame_len_ += frame_len; | 397 frame_len_ += frame_len; |
361 } | 398 } |
362 | 399 |
363 bool QuicHeadersStream::IsConnected() { | 400 bool QuicHeadersStream::IsConnected() { |
364 return session()->connection()->connected(); | 401 return session()->connection()->connected(); |
365 } | 402 } |
366 | 403 |
367 void QuicHeadersStream::DisableHpackDynamicTable() { | 404 void QuicHeadersStream::DisableHpackDynamicTable() { |
368 spdy_framer_.UpdateHeaderEncoderTableSize(0); | 405 spdy_framer_.UpdateHeaderEncoderTableSize(0); |
369 } | 406 } |
370 | 407 |
371 } // namespace net | 408 } // namespace net |
OLD | NEW |