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

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

Issue 1989003002: QUIC - add instrumentation to HPACK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase-update Created 4 years, 7 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_headers_stream.h ('k') | net/quic/quic_headers_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_header_list.h" 12 #include "net/quic/quic_header_list.h"
13 #include "net/quic/quic_headers_stream.h" 13 #include "net/quic/quic_headers_stream.h"
14 #include "net/quic/quic_spdy_session.h" 14 #include "net/quic/quic_spdy_session.h"
15 #include "net/quic/quic_time.h" 15 #include "net/quic/quic_time.h"
16 16
17 using base::StringPiece; 17 using base::StringPiece;
18 using net::HTTP2; 18 using net::HTTP2;
19 using net::SpdyFrameType; 19 using net::SpdyFrameType;
20 using std::string; 20 using std::string;
21 21
22 namespace net { 22 namespace net {
23 23
24 namespace {
25
26 class HeaderTableDebugVisitor : public HpackHeaderTable::DebugVisitorInterface {
27 public:
28 HeaderTableDebugVisitor(
29 const QuicClock* clock,
30 std::unique_ptr<QuicHeadersStream::HpackDebugVisitor> visitor)
31 : clock_(clock), headers_stream_hpack_visitor_(std::move(visitor)) {}
32
33 int64_t OnNewEntry(const HpackEntry& entry) override {
34 DVLOG(1) << entry.GetDebugString();
35 return clock_->ApproximateNow().Subtract(QuicTime::Zero()).ToMicroseconds();
36 }
37
38 void OnUseEntry(const HpackEntry& entry) override {
39 const QuicTime::Delta elapsed(
40 clock_->ApproximateNow()
41 .Subtract(QuicTime::Delta::FromMicroseconds(entry.time_added()))
42 .Subtract(QuicTime::Zero()));
43 DVLOG(1) << entry.GetDebugString() << " " << elapsed.ToMilliseconds()
44 << " ms";
45 headers_stream_hpack_visitor_->OnUseEntry(elapsed);
46 }
47
48 private:
49 const QuicClock* clock_;
50 std::unique_ptr<QuicHeadersStream::HpackDebugVisitor>
51 headers_stream_hpack_visitor_;
52
53 DISALLOW_COPY_AND_ASSIGN(HeaderTableDebugVisitor);
54 };
55
56 } // namespace
57
58 QuicHeadersStream::HpackDebugVisitor::HpackDebugVisitor() {}
59
60 QuicHeadersStream::HpackDebugVisitor::~HpackDebugVisitor() {}
61
24 // A SpdyFramer visitor which passed SYN_STREAM and SYN_REPLY frames to 62 // A SpdyFramer visitor which passed SYN_STREAM and SYN_REPLY frames to
25 // the QuicSpdyStream, and closes the connection if any unexpected frames 63 // the QuicSpdyStream, and closes the connection if any unexpected frames
26 // are received. 64 // are received.
27 class QuicHeadersStream::SpdyFramerVisitor 65 class QuicHeadersStream::SpdyFramerVisitor
28 : public SpdyFramerVisitorInterface, 66 : public SpdyFramerVisitorInterface,
29 public SpdyFramerDebugVisitorInterface { 67 public SpdyFramerDebugVisitorInterface {
30 public: 68 public:
31 explicit SpdyFramerVisitor(QuicHeadersStream* stream) : stream_(stream) {} 69 explicit SpdyFramerVisitor(QuicHeadersStream* stream) : stream_(stream) {}
32 70
33 // SpdyFramerVisitorInterface implementation 71 // SpdyFramerVisitorInterface implementation
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 448 }
411 449
412 bool QuicHeadersStream::IsConnected() { 450 bool QuicHeadersStream::IsConnected() {
413 return session()->connection()->connected(); 451 return session()->connection()->connected();
414 } 452 }
415 453
416 void QuicHeadersStream::DisableHpackDynamicTable() { 454 void QuicHeadersStream::DisableHpackDynamicTable() {
417 spdy_framer_.UpdateHeaderEncoderTableSize(0); 455 spdy_framer_.UpdateHeaderEncoderTableSize(0);
418 } 456 }
419 457
458 void QuicHeadersStream::SetHpackEncoderDebugVisitor(
459 std::unique_ptr<HpackDebugVisitor> visitor) {
460 spdy_framer_.SetEncoderHeaderTableDebugVisitor(
461 std::unique_ptr<HeaderTableDebugVisitor>(new HeaderTableDebugVisitor(
462 session()->connection()->helper()->GetClock(), std::move(visitor))));
463 }
464
465 void QuicHeadersStream::SetHpackDecoderDebugVisitor(
466 std::unique_ptr<HpackDebugVisitor> visitor) {
467 spdy_framer_.SetDecoderHeaderTableDebugVisitor(
468 std::unique_ptr<HeaderTableDebugVisitor>(new HeaderTableDebugVisitor(
469 session()->connection()->helper()->GetClock(), std::move(visitor))));
470 }
471
420 } // namespace net 472 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_headers_stream.h ('k') | net/quic/quic_headers_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698