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 | |
| 26 | void OnIncomingAck(const QuicAckFrame& ack_frame, |
| 27 | QuicTime ack_receive_time, |
| 28 | QuicPacketNumber largest_observed, |
| 29 | bool rtt_updated, |
| 30 | QuicPacketNumber least_unacked_sent_packet) override; |
| 31 | |
| 32 | void OnPacketLoss(QuicPacketNumber lost_packet_number, |
| 33 | TransmissionType transmission_type, |
| 34 | QuicTime detection_time) override; |
| 35 | |
| 36 | void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame, |
| 37 | const QuicTime& receive_time) override; |
| 38 | |
| 39 | void OnSuccessfulVersionNegotiation( |
| 40 | const ParsedQuicVersion& version) override; |
| 41 | |
| 42 | void OnApplicationLimited() override; |
| 43 | |
| 44 | void OnAdjustNetworkParameters(QuicBandwidth bandwidth, |
fayang | be83ecd | 2019-04-26 13:58:09 -0700 | [diff] [blame] | 45 | QuicTime::Delta rtt, |
| 46 | QuicByteCount old_cwnd, |
| 47 | QuicByteCount new_cwnd) override; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 48 | |
| 49 | // Returns a mutable pointer to the trace. The trace is owned by the |
| 50 | // visitor, but can be moved using Swap() method after the connection is |
| 51 | // finished. |
| 52 | quic_trace::Trace* trace() { return &trace_; } |
| 53 | |
| 54 | private: |
| 55 | // Converts QuicTime into a microsecond delta w.r.t. the beginning of the |
| 56 | // connection. |
| 57 | uint64_t ConvertTimestampToRecordedFormat(QuicTime timestamp); |
| 58 | // Populates a quic_trace::Frame message from |frame|. |
| 59 | void PopulateFrameInfo(const QuicFrame& frame, |
| 60 | quic_trace::Frame* frame_record); |
| 61 | // Populates a quic_trace::TransportState message from the associated |
| 62 | // connection. |
| 63 | void PopulateTransportState(quic_trace::TransportState* state); |
| 64 | |
| 65 | quic_trace::Trace trace_; |
| 66 | const QuicConnection* connection_; |
| 67 | const QuicTime start_time_; |
| 68 | }; |
| 69 | |
| 70 | } // namespace quic |
| 71 | |
| 72 | #endif // QUICHE_QUIC_CORE_QUIC_TRACE_VISITOR_H_ |