1 // Copyright (c) 2013 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 NET_QUIC_QUIC_CONNECTION_LOGGER_H_ 6 #define NET_QUIC_QUIC_CONNECTION_LOGGER_H_ 7 8 #include "net/quic/quic_connection.h" 9 #include "net/quic/quic_protocol.h" 10 11 namespace net { 12 13 class BoundNetLog; 14 class CryptoHandshakeMessage; 15 16 // This class is a debug visitor of a QuicConnection which logs 17 // events to |net_log|. 18 class NET_EXPORT_PRIVATE QuicConnectionLogger 19 : public QuicConnectionDebugVisitorInterface { 20 public: 21 explicit QuicConnectionLogger(const BoundNetLog& net_log); 22 23 virtual ~QuicConnectionLogger(); 24 25 // QuicPacketGenerator::DebugDelegateInterface 26 virtual void OnFrameAddedToPacket(const QuicFrame& frame) OVERRIDE; 27 28 // QuicConnectionDebugVisitorInterface 29 virtual void OnPacketSent(QuicPacketSequenceNumber sequence_number, 30 EncryptionLevel level, 31 const QuicEncryptedPacket& packet, 32 WriteResult result) OVERRIDE; 33 virtual void OnPacketRetransmitted( 34 QuicPacketSequenceNumber old_sequence_number, 35 QuicPacketSequenceNumber new_sequence_number) OVERRIDE; 36 virtual void OnPacketReceived(const IPEndPoint& self_address, 37 const IPEndPoint& peer_address, 38 const QuicEncryptedPacket& packet) OVERRIDE; 39 virtual void OnProtocolVersionMismatch(QuicVersion version) OVERRIDE; 40 virtual void OnPacketHeader(const QuicPacketHeader& header) OVERRIDE; 41 virtual void OnStreamFrame(const QuicStreamFrame& frame) OVERRIDE; 42 virtual void OnAckFrame(const QuicAckFrame& frame) OVERRIDE; 43 virtual void OnCongestionFeedbackFrame( 44 const QuicCongestionFeedbackFrame& frame) OVERRIDE; 45 virtual void OnRstStreamFrame(const QuicRstStreamFrame& frame) OVERRIDE; 46 virtual void OnConnectionCloseFrame( 47 const QuicConnectionCloseFrame& frame) OVERRIDE; 48 virtual void OnPublicResetPacket( 49 const QuicPublicResetPacket& packet) OVERRIDE; 50 virtual void OnVersionNegotiationPacket( 51 const QuicVersionNegotiationPacket& packet) OVERRIDE; 52 virtual void OnRevivedPacket(const QuicPacketHeader& revived_header, 53 base::StringPiece payload) OVERRIDE; 54 55 void OnCryptoHandshakeMessageReceived( 56 const CryptoHandshakeMessage& message); 57 void OnCryptoHandshakeMessageSent( 58 const CryptoHandshakeMessage& message); 59 void OnConnectionClosed(QuicErrorCode error, bool from_peer); 60 void OnSuccessfulVersionNegotiation(const QuicVersion& version); 61 62 private: 63 BoundNetLog net_log_; 64 // The last packet sequence number received. 65 QuicPacketSequenceNumber last_received_packet_sequence_number_; 66 // The largest packet sequence number received. In case of that a packet is 67 // received late, this value will not be updated. 68 QuicPacketSequenceNumber largest_received_packet_sequence_number_; 69 // The largest packet sequence number which the peer has failed to 70 // receive, according to the missing packet set in their ack frames. 71 QuicPacketSequenceNumber largest_received_missing_packet_sequence_number_; 72 // Number of times that the current received packet sequence number is 73 // smaller than the last received packet sequence number. 74 size_t out_of_order_recieved_packet_count_; 75 DISALLOW_COPY_AND_ASSIGN(QuicConnectionLogger); 76 }; 77 78 } // namespace net 79 80 #endif // NET_QUIC_QUIC_CONNECTION_LOGGER_H_ 81