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