OLD | NEW |
(Empty) | |
| 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_ACK_NOTIFIER_H_ |
| 6 #define NET_QUIC_QUIC_ACK_NOTIFIER_H_ |
| 7 |
| 8 #include "base/callback.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: |
| 22 DelegateInterface(); |
| 23 virtual ~DelegateInterface(); |
| 24 virtual void OnAckNotification() = 0; |
| 25 }; |
| 26 |
| 27 explicit QuicAckNotifier(DelegateInterface* delegate); |
| 28 virtual ~QuicAckNotifier(); |
| 29 |
| 30 // Register a sequence number that this AckNotifier should be interested in. |
| 31 void AddSequenceNumber(const QuicPacketSequenceNumber& sequence_number); |
| 32 |
| 33 // Register a set of sequence numbers that this AckNotifier should be |
| 34 // interested in. |
| 35 void AddSequenceNumbers(const SequenceNumberSet& sequence_numbers); |
| 36 |
| 37 // Called by the QuicConnection on receipt of new ACK frames with a list of |
| 38 // ACKed sequence numbers. |
| 39 // Deletes any matching sequence numbers from the set of sequence numbers |
| 40 // being tracked. If this set is now empty, call the stored delegate's |
| 41 // OnAckNotification method. |
| 42 // |
| 43 // Returns true if the provided sequence_numbers caused the delegate to be |
| 44 // called, false otherwise. |
| 45 bool OnAck(SequenceNumberSet sequence_numbers); |
| 46 |
| 47 // If a packet is retransmitted by the connection it will be sent with a |
| 48 // different sequence number. Updates our internal set of sequence_numbers to |
| 49 // track the latest number. |
| 50 void UpdateSequenceNumber(QuicPacketSequenceNumber old_sequence_number, |
| 51 QuicPacketSequenceNumber new_sequence_number); |
| 52 |
| 53 private: |
| 54 // The delegate's OnAckNotification() method will be called once we have been |
| 55 // notified of ACKs for all the sequence numbers we are tracking. |
| 56 // This is not owned by OnAckNotifier and must outlive it. |
| 57 DelegateInterface* delegate_; |
| 58 |
| 59 // Set of sequence numbers this notifier is waiting to hear about. The |
| 60 // delegate will not be called until this is an empty set. |
| 61 SequenceNumberSet sequence_numbers_; |
| 62 }; |
| 63 |
| 64 }; // namespace net |
| 65 |
| 66 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_H_ |
OLD | NEW |