blob: 0494d87433182f56d3b06e6fb62516291e9d37e9 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright (c) 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef QUICHE_QUIC_CORE_QUIC_TRACE_VISITOR_H_
6#define QUICHE_QUIC_CORE_QUIC_TRACE_VISITOR_H_
7
8#include "net/third_party/quiche/src/quic/core/quic_connection.h"
9#include "net/third_party/quiche/src/quic/core/quic_types.h"
10#include "third_party/quic_trace/lib/quic_trace.pb.h"
11
12namespace quic {
13
14// Records a QUIC trace protocol buffer for a QuicConnection. It's the
15// responsibility of the user of this visitor to process or store the resulting
16// trace, which can be accessed via trace().
17class QuicTraceVisitor : public QuicConnectionDebugVisitor {
18 public:
19 explicit QuicTraceVisitor(const QuicConnection* connection);
20
21 void OnPacketSent(const SerializedPacket& serialized_packet,
22 QuicPacketNumber original_packet_number,
23 TransmissionType transmission_type,
24 QuicTime sent_time) override;
25
fayangf8e918b2019-07-16 13:03:16 -070026 void OnIncomingAck(QuicPacketNumber ack_packet_number,
27 const QuicAckFrame& ack_frame,
QUICHE teama6ef0a62019-03-07 20:34:33 -050028 QuicTime ack_receive_time,
29 QuicPacketNumber largest_observed,
30 bool rtt_updated,
31 QuicPacketNumber least_unacked_sent_packet) override;
32
33 void OnPacketLoss(QuicPacketNumber lost_packet_number,
34 TransmissionType transmission_type,
35 QuicTime detection_time) override;
36
37 void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame,
38 const QuicTime& receive_time) override;
39
40 void OnSuccessfulVersionNegotiation(
41 const ParsedQuicVersion& version) override;
42
43 void OnApplicationLimited() override;
44
45 void OnAdjustNetworkParameters(QuicBandwidth bandwidth,
fayangbe83ecd2019-04-26 13:58:09 -070046 QuicTime::Delta rtt,
47 QuicByteCount old_cwnd,
48 QuicByteCount new_cwnd) override;
QUICHE teama6ef0a62019-03-07 20:34:33 -050049
50 // Returns a mutable pointer to the trace. The trace is owned by the
51 // visitor, but can be moved using Swap() method after the connection is
52 // finished.
53 quic_trace::Trace* trace() { return &trace_; }
54
55 private:
56 // Converts QuicTime into a microsecond delta w.r.t. the beginning of the
57 // connection.
58 uint64_t ConvertTimestampToRecordedFormat(QuicTime timestamp);
59 // Populates a quic_trace::Frame message from |frame|.
60 void PopulateFrameInfo(const QuicFrame& frame,
61 quic_trace::Frame* frame_record);
62 // Populates a quic_trace::TransportState message from the associated
63 // connection.
64 void PopulateTransportState(quic_trace::TransportState* state);
65
66 quic_trace::Trace trace_;
67 const QuicConnection* connection_;
68 const QuicTime start_time_;
69};
70
71} // namespace quic
72
73#endif // QUICHE_QUIC_CORE_QUIC_TRACE_VISITOR_H_