| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_QUIC_QUIC_ACK_NOTIFIER_H_ | |
| 6 #define NET_QUIC_QUIC_ACK_NOTIFIER_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "net/quic/quic_protocol.h" | |
| 10 | |
| 11 namespace net { | |
| 12 | |
| 13 // Used to register with a QuicConnection for notification once a set of packets | |
| 14 // have all been ACKed. | |
| 15 // The connection informs this class of newly ACKed sequence numbers, and once | |
| 16 // we have seen ACKs for all the sequence numbers we are interested in, we | |
| 17 // trigger a call to a provided Closure. | |
| 18 class NET_EXPORT_PRIVATE QuicAckNotifier { | |
| 19 public: | |
| 20 class NET_EXPORT_PRIVATE DelegateInterface | |
| 21 : public base::RefCounted<DelegateInterface> { | |
| 22 public: | |
| 23 DelegateInterface(); | |
| 24 // Args: | |
| 25 // num_retransmitted_packets - Number of packets that had to be | |
| 26 // retransmitted. | |
| 27 // num_retransmitted_bytes - Number of bytes that had to be retransmitted. | |
| 28 virtual void OnAckNotification(int num_retransmitted_packets, | |
| 29 int num_retransmitted_bytes, | |
| 30 QuicTime::Delta delta_largest_observed) = 0; | |
| 31 | |
| 32 protected: | |
| 33 friend class base::RefCounted<DelegateInterface>; | |
| 34 | |
| 35 // Delegates are ref counted. | |
| 36 virtual ~DelegateInterface(); | |
| 37 }; | |
| 38 | |
| 39 // QuicAckNotifier is expected to keep its own reference to the delegate. | |
| 40 explicit QuicAckNotifier(DelegateInterface* delegate); | |
| 41 virtual ~QuicAckNotifier(); | |
| 42 | |
| 43 // Register a serialized packet the notifier should track. | |
| 44 void OnSerializedPacket(); | |
| 45 | |
| 46 // Called on receipt of new ACK frame for an unacked packet. | |
| 47 // Decrements the number of unacked packets and if there are none left, calls | |
| 48 // the stored delegate's OnAckNotification method. | |
| 49 // | |
| 50 // Returns true if the delegate was called, false otherwise. | |
| 51 bool OnAck(QuicTime::Delta delta_largest_observed); | |
| 52 | |
| 53 // Called when we've given up waiting for a sequence number, typically when | |
| 54 // the connection is torn down. | |
| 55 // Returns true if there are no more unacked packets being tracked. | |
| 56 bool OnPacketAbandoned(); | |
| 57 | |
| 58 bool HasUnackedPackets() const { return unacked_packets_ > 0; } | |
| 59 | |
| 60 // If a packet is retransmitted by the connection, it will be sent with a | |
| 61 // different sequence number. | |
| 62 void OnPacketRetransmitted(int packet_payload_size); | |
| 63 | |
| 64 private: | |
| 65 // The delegate's OnAckNotification() method will be called once we have been | |
| 66 // notified of ACKs for all the sequence numbers we are tracking. | |
| 67 // This is not owned by OnAckNotifier and must outlive it. | |
| 68 scoped_refptr<DelegateInterface> delegate_; | |
| 69 | |
| 70 // The number of unacked packets being tracked. | |
| 71 int unacked_packets_; | |
| 72 | |
| 73 // Number of packets that had to be retransmitted. | |
| 74 int retransmitted_packet_count_; | |
| 75 // Number of bytes that had to be retransmitted. | |
| 76 int retransmitted_byte_count_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(QuicAckNotifier); | |
| 79 }; | |
| 80 | |
| 81 } // namespace net | |
| 82 | |
| 83 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_H_ | |
| OLD | NEW |