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.
5 #ifndef NET_QUIC_QUIC_ACK_NOTIFIER_H_
6 #define NET_QUIC_QUIC_ACK_NOTIFIER_H_
8 #include "net/quic/quic_protocol.h"
12 // Used to register with a QuicConnection for notification once a set of packets
13 // have all been ACKed.
14 // The connection informs this class of newly ACKed sequence numbers, and once
15 // we have seen ACKs for all the sequence numbers we are interested in, we
16 // trigger a call to a provided Closure.
17 class NET_EXPORT_PRIVATE QuicAckNotifier
{
19 class NET_EXPORT_PRIVATE DelegateInterface
{
22 virtual ~DelegateInterface();
23 virtual void OnAckNotification() = 0;
26 explicit QuicAckNotifier(DelegateInterface
* delegate
);
27 virtual ~QuicAckNotifier();
29 // Register a sequence number that this AckNotifier should be interested in.
30 void AddSequenceNumber(const QuicPacketSequenceNumber
& sequence_number
);
32 // Register a set of sequence numbers that this AckNotifier should be
34 void AddSequenceNumbers(const SequenceNumberSet
& sequence_numbers
);
36 // Called by the QuicConnection on receipt of new ACK frame, with the sequence
37 // number referenced by the ACK frame.
38 // Deletes the matching sequence number from the stored set of sequence
39 // numbers. If this set is now empty, call the stored delegate's
40 // OnAckNotification method.
42 // Returns true if the provided sequence_number caused the delegate to be
43 // called, false otherwise.
44 bool OnAck(QuicPacketSequenceNumber sequence_number
);
46 bool IsEmpty() { return sequence_numbers_
.empty(); }
48 // If a packet is retransmitted by the connection it will be sent with a
49 // different sequence number. Updates our internal set of sequence_numbers to
50 // track the latest number.
51 void UpdateSequenceNumber(QuicPacketSequenceNumber old_sequence_number
,
52 QuicPacketSequenceNumber new_sequence_number
);
55 // The delegate's OnAckNotification() method will be called once we have been
56 // notified of ACKs for all the sequence numbers we are tracking.
57 // This is not owned by OnAckNotifier and must outlive it.
58 DelegateInterface
* delegate_
;
60 // Set of sequence numbers this notifier is waiting to hear about. The
61 // delegate will not be called until this is an empty set.
62 SequenceNumberSet sequence_numbers_
;
67 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_H_