| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 class HeaderTableDebugVisitor : public HpackHeaderTable::DebugVisitorInterface { | 29 class HeaderTableDebugVisitor : public HpackHeaderTable::DebugVisitorInterface { |
| 30 public: | 30 public: |
| 31 HeaderTableDebugVisitor( | 31 HeaderTableDebugVisitor( |
| 32 const QuicClock* clock, | 32 const QuicClock* clock, |
| 33 std::unique_ptr<QuicHeadersStream::HpackDebugVisitor> visitor) | 33 std::unique_ptr<QuicHeadersStream::HpackDebugVisitor> visitor) |
| 34 : clock_(clock), headers_stream_hpack_visitor_(std::move(visitor)) {} | 34 : clock_(clock), headers_stream_hpack_visitor_(std::move(visitor)) {} |
| 35 | 35 |
| 36 int64_t OnNewEntry(const HpackEntry& entry) override { | 36 int64_t OnNewEntry(const HpackEntry& entry) override { |
| 37 DVLOG(1) << entry.GetDebugString(); | 37 DVLOG(1) << entry.GetDebugString(); |
| 38 return clock_->ApproximateNow().Subtract(QuicTime::Zero()).ToMicroseconds(); | 38 return (clock_->ApproximateNow() - QuicTime::Zero()).ToMicroseconds(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void OnUseEntry(const HpackEntry& entry) override { | 41 void OnUseEntry(const HpackEntry& entry) override { |
| 42 const QuicTime::Delta elapsed( | 42 const QuicTime::Delta elapsed( |
| 43 clock_->ApproximateNow() | 43 clock_->ApproximateNow() - |
| 44 .Subtract(QuicTime::Delta::FromMicroseconds(entry.time_added())) | 44 QuicTime::Delta::FromMicroseconds(entry.time_added()) - |
| 45 .Subtract(QuicTime::Zero())); | 45 QuicTime::Zero()); |
| 46 DVLOG(1) << entry.GetDebugString() << " " << elapsed.ToMilliseconds() | 46 DVLOG(1) << entry.GetDebugString() << " " << elapsed.ToMilliseconds() |
| 47 << " ms"; | 47 << " ms"; |
| 48 headers_stream_hpack_visitor_->OnUseEntry(elapsed); | 48 headers_stream_hpack_visitor_->OnUseEntry(elapsed); |
| 49 } | 49 } |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 const QuicClock* clock_; | 52 const QuicClock* clock_; |
| 53 std::unique_ptr<QuicHeadersStream::HpackDebugVisitor> | 53 std::unique_ptr<QuicHeadersStream::HpackDebugVisitor> |
| 54 headers_stream_hpack_visitor_; | 54 headers_stream_hpack_visitor_; |
| 55 | 55 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 DCHECK_EQ(stream_id_, stream_id); | 501 DCHECK_EQ(stream_id_, stream_id); |
| 502 if (len == 0) { | 502 if (len == 0) { |
| 503 DCHECK_NE(0u, stream_id_); | 503 DCHECK_NE(0u, stream_id_); |
| 504 DCHECK_NE(0u, frame_len_); | 504 DCHECK_NE(0u, frame_len_); |
| 505 if (measure_headers_hol_blocking_time_) { | 505 if (measure_headers_hol_blocking_time_) { |
| 506 if (prev_max_timestamp_ > cur_max_timestamp_) { | 506 if (prev_max_timestamp_ > cur_max_timestamp_) { |
| 507 // prev_max_timestamp_ > cur_max_timestamp_ implies that | 507 // prev_max_timestamp_ > cur_max_timestamp_ implies that |
| 508 // headers from lower numbered streams actually came off the | 508 // headers from lower numbered streams actually came off the |
| 509 // wire after headers for the current stream, hence there was | 509 // wire after headers for the current stream, hence there was |
| 510 // HOL blocking. | 510 // HOL blocking. |
| 511 QuicTime::Delta delta(prev_max_timestamp_.Subtract(cur_max_timestamp_)); | 511 QuicTime::Delta delta = prev_max_timestamp_ - cur_max_timestamp_; |
| 512 DVLOG(1) << "stream " << stream_id | 512 DVLOG(1) << "stream " << stream_id |
| 513 << ": Net.QuicSession.HeadersHOLBlockedTime " | 513 << ": Net.QuicSession.HeadersHOLBlockedTime " |
| 514 << delta.ToMilliseconds(); | 514 << delta.ToMilliseconds(); |
| 515 spdy_session_->OnHeadersHeadOfLineBlocking(delta); | 515 spdy_session_->OnHeadersHeadOfLineBlocking(delta); |
| 516 } | 516 } |
| 517 prev_max_timestamp_ = std::max(prev_max_timestamp_, cur_max_timestamp_); | 517 prev_max_timestamp_ = std::max(prev_max_timestamp_, cur_max_timestamp_); |
| 518 cur_max_timestamp_ = QuicTime::Zero(); | 518 cur_max_timestamp_ = QuicTime::Zero(); |
| 519 } | 519 } |
| 520 if (promised_stream_id_ == kInvalidStreamId) { | 520 if (promised_stream_id_ == kInvalidStreamId) { |
| 521 spdy_session_->OnStreamHeadersComplete(stream_id_, fin_, frame_len_); | 521 spdy_session_->OnStreamHeadersComplete(stream_id_, fin_, frame_len_); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 548 | 548 |
| 549 void QuicHeadersStream::OnHeaderList(const QuicHeaderList& header_list) { | 549 void QuicHeadersStream::OnHeaderList(const QuicHeaderList& header_list) { |
| 550 DVLOG(1) << "Received header list for stream " << stream_id_ << ": " | 550 DVLOG(1) << "Received header list for stream " << stream_id_ << ": " |
| 551 << header_list.DebugString(); | 551 << header_list.DebugString(); |
| 552 if (measure_headers_hol_blocking_time_) { | 552 if (measure_headers_hol_blocking_time_) { |
| 553 if (prev_max_timestamp_ > cur_max_timestamp_) { | 553 if (prev_max_timestamp_ > cur_max_timestamp_) { |
| 554 // prev_max_timestamp_ > cur_max_timestamp_ implies that | 554 // prev_max_timestamp_ > cur_max_timestamp_ implies that |
| 555 // headers from lower numbered streams actually came off the | 555 // headers from lower numbered streams actually came off the |
| 556 // wire after headers for the current stream, hence there was | 556 // wire after headers for the current stream, hence there was |
| 557 // HOL blocking. | 557 // HOL blocking. |
| 558 QuicTime::Delta delta = prev_max_timestamp_.Subtract(cur_max_timestamp_); | 558 QuicTime::Delta delta = prev_max_timestamp_ - cur_max_timestamp_; |
| 559 DVLOG(1) << "stream " << stream_id_ | 559 DVLOG(1) << "stream " << stream_id_ |
| 560 << ": Net.QuicSession.HeadersHOLBlockedTime " | 560 << ": Net.QuicSession.HeadersHOLBlockedTime " |
| 561 << delta.ToMilliseconds(); | 561 << delta.ToMilliseconds(); |
| 562 spdy_session_->OnHeadersHeadOfLineBlocking(delta); | 562 spdy_session_->OnHeadersHeadOfLineBlocking(delta); |
| 563 } | 563 } |
| 564 prev_max_timestamp_ = std::max(prev_max_timestamp_, cur_max_timestamp_); | 564 prev_max_timestamp_ = std::max(prev_max_timestamp_, cur_max_timestamp_); |
| 565 cur_max_timestamp_ = QuicTime::Zero(); | 565 cur_max_timestamp_ = QuicTime::Zero(); |
| 566 } | 566 } |
| 567 if (promised_stream_id_ == kInvalidStreamId) { | 567 if (promised_stream_id_ == kInvalidStreamId) { |
| 568 spdy_session_->OnStreamHeaderList(stream_id_, fin_, frame_len_, | 568 spdy_session_->OnStreamHeaderList(stream_id_, fin_, frame_len_, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 return true; | 638 return true; |
| 639 } | 639 } |
| 640 frame_len_ -= len; | 640 frame_len_ -= len; |
| 641 // Ignore fin_ while there is more data coming, if frame_len_ > 0. | 641 // Ignore fin_ while there is more data coming, if frame_len_ > 0. |
| 642 spdy_session_->OnStreamFrameData(stream_id, data, len, | 642 spdy_session_->OnStreamFrameData(stream_id, data, len, |
| 643 frame_len_ > 0 ? false : fin_); | 643 frame_len_ > 0 ? false : fin_); |
| 644 return true; | 644 return true; |
| 645 } | 645 } |
| 646 | 646 |
| 647 } // namespace net | 647 } // namespace net |
| OLD | NEW |