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_MANAGER_H_ | |
6 #define NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_ | |
7 | |
8 #include <list> | |
9 #include <map> | |
10 | |
11 #include "base/containers/hash_tables.h" | |
12 #include "net/quic/quic_protocol.h" | |
13 | |
14 namespace net { | |
15 | |
16 class QuicAckNotifier; | |
17 | |
18 // The AckNotifierManager is used by the QuicSentPacketManager to keep track of | |
19 // all the AckNotifiers currently active. It owns the AckNotifiers which it gets | |
20 // from the serialized packets passed into OnSerializedPacket. It maintains both | |
21 // a set of AckNotifiers and a map from sequence number to AckNotifier the sake | |
22 // of efficiency - we can quickly check the map to see if any AckNotifiers are | |
23 // interested in a given sequence number. | |
24 class NET_EXPORT_PRIVATE AckNotifierManager { | |
25 public: | |
26 AckNotifierManager(); | |
27 virtual ~AckNotifierManager(); | |
28 | |
29 // Called when the connection receives a new AckFrame. If |sequence_number| | |
30 // exists in ack_notifier_map_ then the corresponding AckNotifiers will have | |
31 // their OnAck method called. | |
32 void OnPacketAcked(QuicPacketSequenceNumber sequence_number, | |
33 QuicTime::Delta delta_largest_observed); | |
34 | |
35 // If a packet has been retransmitted with a new sequence number, then this | |
36 // will be called. It updates the mapping in ack_notifier_map_, and also | |
37 // updates the internal set of sequence numbers in each matching AckNotifier. | |
38 void OnPacketRetransmitted(QuicPacketSequenceNumber old_sequence_number, | |
39 QuicPacketSequenceNumber new_sequence_number, | |
40 int packet_payload_size); | |
41 | |
42 // This is called after a packet has been serialized, is ready to be sent, and | |
43 // contains retransmittable frames (which may have associated AckNotifiers). | |
44 // If any of the retransmittable frames included in |serialized_packet| have | |
45 // AckNotifiers registered, then add them to our internal map and additionally | |
46 // inform the AckNotifier of the sequence number which it should track. | |
47 void OnSerializedPacket(const SerializedPacket& serialized_packet); | |
48 | |
49 private: | |
50 typedef std::list<QuicAckNotifier*> AckNotifierList; | |
51 // TODO(ianswett): Further improvement may come from changing this to a deque. | |
52 typedef base::hash_map<QuicPacketSequenceNumber, AckNotifierList> | |
53 AckNotifierMap; | |
54 | |
55 // Maps from sequence number to the AckNotifiers which are registered | |
56 // for that sequence number. On receipt of an ACK for a given sequence | |
57 // number, call OnAck for all mapped AckNotifiers. | |
58 // When the last reference is removed from the map, the notifier is deleted. | |
59 AckNotifierMap ack_notifier_map_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(AckNotifierManager); | |
62 }; | |
63 | |
64 } // namespace net | |
65 | |
66 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_ | |
OLD | NEW |