QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // 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 | |
| 12 | namespace 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(). |
| 17 | class 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 | |
fayang | f8e918b | 2019-07-16 13:03:16 -0700 | [diff] [blame] | 26 | void OnIncomingAck(QuicPacketNumber ack_packet_number, |
| 27 | const QuicAckFrame& ack_frame, |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 28 | 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, |
fayang | be83ecd | 2019-04-26 13:58:09 -0700 | [diff] [blame] | 46 | QuicTime::Delta rtt, |
| 47 | QuicByteCount old_cwnd, |
| 48 | QuicByteCount new_cwnd) override; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 49 | |
| 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_ |