| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 DCHECK_EQ(stream_id_, stream_id); | 398 DCHECK_EQ(stream_id_, stream_id); |
| 399 if (len == 0) { | 399 if (len == 0) { |
| 400 DCHECK_NE(0u, stream_id_); | 400 DCHECK_NE(0u, stream_id_); |
| 401 DCHECK_NE(0u, frame_len_); | 401 DCHECK_NE(0u, frame_len_); |
| 402 if (measure_headers_hol_blocking_time_) { | 402 if (measure_headers_hol_blocking_time_) { |
| 403 if (prev_max_timestamp_ > cur_max_timestamp_) { | 403 if (prev_max_timestamp_ > cur_max_timestamp_) { |
| 404 // prev_max_timestamp_ > cur_max_timestamp_ implies that | 404 // prev_max_timestamp_ > cur_max_timestamp_ implies that |
| 405 // headers from lower numbered streams actually came off the | 405 // headers from lower numbered streams actually came off the |
| 406 // wire after headers for the current stream, hence there was | 406 // wire after headers for the current stream, hence there was |
| 407 // HOL blocking. | 407 // HOL blocking. |
| 408 QuicTime::Delta delta(prev_max_timestamp_.Subtract(cur_max_timestamp_)); | 408 QuicTime::Delta delta = prev_max_timestamp_ - cur_max_timestamp_; |
| 409 DVLOG(1) << "stream " << stream_id | 409 DVLOG(1) << "stream " << stream_id |
| 410 << ": Net.QuicSession.HeadersHOLBlockedTime " | 410 << ": Net.QuicSession.HeadersHOLBlockedTime " |
| 411 << delta.ToMilliseconds(); | 411 << delta.ToMilliseconds(); |
| 412 spdy_session_->OnHeadersHeadOfLineBlocking(delta); | 412 spdy_session_->OnHeadersHeadOfLineBlocking(delta); |
| 413 } | 413 } |
| 414 prev_max_timestamp_ = std::max(prev_max_timestamp_, cur_max_timestamp_); | 414 prev_max_timestamp_ = std::max(prev_max_timestamp_, cur_max_timestamp_); |
| 415 cur_max_timestamp_ = QuicTime::Zero(); | 415 cur_max_timestamp_ = QuicTime::Zero(); |
| 416 } | 416 } |
| 417 if (promised_stream_id_ == kInvalidStreamId) { | 417 if (promised_stream_id_ == kInvalidStreamId) { |
| 418 spdy_session_->OnStreamHeadersComplete(stream_id_, fin_, frame_len_); | 418 spdy_session_->OnStreamHeadersComplete(stream_id_, fin_, frame_len_); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 445 | 445 |
| 446 void QuicHeadersStream::OnHeaderList(const QuicHeaderList& header_list) { | 446 void QuicHeadersStream::OnHeaderList(const QuicHeaderList& header_list) { |
| 447 DVLOG(1) << "Received header list for stream " << stream_id_ << ": " | 447 DVLOG(1) << "Received header list for stream " << stream_id_ << ": " |
| 448 << header_list.DebugString(); | 448 << header_list.DebugString(); |
| 449 if (measure_headers_hol_blocking_time_) { | 449 if (measure_headers_hol_blocking_time_) { |
| 450 if (prev_max_timestamp_ > cur_max_timestamp_) { | 450 if (prev_max_timestamp_ > cur_max_timestamp_) { |
| 451 // prev_max_timestamp_ > cur_max_timestamp_ implies that | 451 // prev_max_timestamp_ > cur_max_timestamp_ implies that |
| 452 // headers from lower numbered streams actually came off the | 452 // headers from lower numbered streams actually came off the |
| 453 // wire after headers for the current stream, hence there was | 453 // wire after headers for the current stream, hence there was |
| 454 // HOL blocking. | 454 // HOL blocking. |
| 455 QuicTime::Delta delta = prev_max_timestamp_.Subtract(cur_max_timestamp_); | 455 QuicTime::Delta delta = prev_max_timestamp_ - cur_max_timestamp_; |
| 456 DVLOG(1) << "stream " << stream_id_ | 456 DVLOG(1) << "stream " << stream_id_ |
| 457 << ": Net.QuicSession.HeadersHOLBlockedTime " | 457 << ": Net.QuicSession.HeadersHOLBlockedTime " |
| 458 << delta.ToMilliseconds(); | 458 << delta.ToMilliseconds(); |
| 459 spdy_session_->OnHeadersHeadOfLineBlocking(delta); | 459 spdy_session_->OnHeadersHeadOfLineBlocking(delta); |
| 460 } | 460 } |
| 461 prev_max_timestamp_ = std::max(prev_max_timestamp_, cur_max_timestamp_); | 461 prev_max_timestamp_ = std::max(prev_max_timestamp_, cur_max_timestamp_); |
| 462 cur_max_timestamp_ = QuicTime::Zero(); | 462 cur_max_timestamp_ = QuicTime::Zero(); |
| 463 } | 463 } |
| 464 if (promised_stream_id_ == kInvalidStreamId) { | 464 if (promised_stream_id_ == kInvalidStreamId) { |
| 465 spdy_session_->OnStreamHeaderList(stream_id_, fin_, frame_len_, | 465 spdy_session_->OnStreamHeaderList(stream_id_, fin_, frame_len_, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 spdy_framer_.SetDecoderHeaderTableDebugVisitor( | 500 spdy_framer_.SetDecoderHeaderTableDebugVisitor( |
| 501 std::unique_ptr<HeaderTableDebugVisitor>(new HeaderTableDebugVisitor( | 501 std::unique_ptr<HeaderTableDebugVisitor>(new HeaderTableDebugVisitor( |
| 502 session()->connection()->helper()->GetClock(), std::move(visitor)))); | 502 session()->connection()->helper()->GetClock(), std::move(visitor)))); |
| 503 } | 503 } |
| 504 | 504 |
| 505 void QuicHeadersStream::UpdateHeaderEncoderTableSize(uint32_t value) { | 505 void QuicHeadersStream::UpdateHeaderEncoderTableSize(uint32_t value) { |
| 506 spdy_framer_.UpdateHeaderEncoderTableSize(value); | 506 spdy_framer_.UpdateHeaderEncoderTableSize(value); |
| 507 } | 507 } |
| 508 | 508 |
| 509 } // namespace net | 509 } // namespace net |
| OLD | NEW |