Align base::hash_map with C++11, part 1.
[chromium-blink-merge.git] / net / quic / quic_ack_notifier_manager.h
blob122bda1521f2ee0de2470fcd595f04e1e8909aaf
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 <map>
10 #include "base/containers/hash_tables.h"
11 #include "net/quic/quic_protocol.h"
13 namespace net {
15 class QuicAckNotifier;
17 // The AckNotifierManager is used by the QuicSentPacketManager to keep track of
18 // all the AckNotifiers currently active. It owns the AckNotifiers which it gets
19 // from the serialized packets passed into OnSerializedPacket. It maintains both
20 // a set of AckNotifiers and a map from sequence number to AckNotifier the sake
21 // of efficiency - we can quickly check the map to see if any AckNotifiers are
22 // interested in a given sequence number.
23 class NET_EXPORT_PRIVATE AckNotifierManager {
24 public:
25 AckNotifierManager();
26 virtual ~AckNotifierManager();
28 // Called when the connection receives a new AckFrame. If |sequence_number|
29 // exists in ack_notifier_map_ then the corresponding AckNotifiers will have
30 // their OnAck method called.
31 void OnPacketAcked(QuicPacketSequenceNumber sequence_number,
32 QuicTime::Delta delta_largest_observed);
34 // If a packet has been retransmitted with a new sequence number, then this
35 // will be called. It updates the mapping in ack_notifier_map_, and also
36 // updates the internal set of sequence numbers in each matching AckNotifier.
37 void UpdateSequenceNumber(QuicPacketSequenceNumber old_sequence_number,
38 QuicPacketSequenceNumber new_sequence_number);
40 // This is called after a packet has been serialized, is ready to be sent, and
41 // contains retransmittable frames (which may have associated AckNotifiers).
42 // If any of the retransmittable frames included in |serialized_packet| have
43 // AckNotifiers registered, then add them to our internal map and additionally
44 // inform the AckNotifier of the sequence number which it should track.
45 void OnSerializedPacket(const SerializedPacket& serialized_packet);
47 private:
48 typedef base::hash_set<QuicAckNotifier*> AckNotifierSet;
49 typedef std::map<QuicPacketSequenceNumber, AckNotifierSet> AckNotifierMap;
51 // On every ACK frame received by the connection, all the ack_notifiers_ will
52 // be told which sequeunce numbers were ACKed.
53 // Once a given QuicAckNotifier has seen all the sequence numbers it is
54 // interested in, it will be deleted, and removed from this set.
55 // Owns the AckNotifiers in this set.
56 AckNotifierSet ack_notifiers_;
58 // Maps from sequence number to the AckNotifiers which are registered
59 // for that sequence number. On receipt of an ACK for a given sequence
60 // number, call OnAck for all mapped AckNotifiers.
61 // Does not own the AckNotifiers.
62 AckNotifierMap ack_notifier_map_;
64 DISALLOW_COPY_AND_ASSIGN(AckNotifierManager);
67 } // namespace net
69 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_