Android WebView: add sfntly to deps whitelist.
[chromium-blink-merge.git] / net / quic / quic_ack_notifier_manager.h
blob5ddf794e7bb70dac71bbf72f50c98d949a95751f
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 #if defined(COMPILER_GCC)
14 namespace BASE_HASH_NAMESPACE {
15 template<>
16 struct hash<net::QuicAckNotifier*> {
17 std::size_t operator()(const net::QuicAckNotifier* ptr) const {
18 return hash<size_t>()(reinterpret_cast<size_t>(ptr));
22 #endif
24 namespace net {
26 class QuicAckNotifier;
28 // The AckNotifierManager is used by the QuicSentPacketManager to keep track of
29 // all the AckNotifiers currently active. It owns the AckNotifiers which it gets
30 // from the serialized packets passed into OnSerializedPacket. It maintains both
31 // a set of AckNotifiers and a map from sequence number to AckNotifier the sake
32 // of efficiency - we can quickly check the map to see if any AckNotifiers are
33 // interested in a given sequence number.
35 class NET_EXPORT_PRIVATE AckNotifierManager {
36 public:
37 AckNotifierManager();
38 virtual ~AckNotifierManager();
40 // Called when the connection receives a new AckFrame. If |sequence_number|
41 // exists in ack_notifier_map_ then the corresponding AckNotifiers will have
42 // their OnAck method called.
43 void OnPacketAcked(QuicPacketSequenceNumber sequence_number);
45 // If a packet has been retransmitted with a new sequence number, then this
46 // will be called. It updates the mapping in ack_notifier_map_, and also
47 // updates the internal set of sequence numbers in each matching AckNotifier.
48 void UpdateSequenceNumber(QuicPacketSequenceNumber old_sequence_number,
49 QuicPacketSequenceNumber new_sequence_number);
51 // This is called after a packet has been serialized, is ready to be sent, and
52 // contains retransmittable frames (which may have associated AckNotifiers).
53 // If any of the retransmittable frames included in |serialized_packet| have
54 // AckNotifiers registered, then add them to our internal map and additionally
55 // inform the AckNotifier of the sequence number which it should track.
56 void OnSerializedPacket(const SerializedPacket& serialized_packet);
58 private:
59 typedef base::hash_set<QuicAckNotifier*> AckNotifierSet;
60 typedef std::map<QuicPacketSequenceNumber, AckNotifierSet> AckNotifierMap;
62 // On every ACK frame received by the connection, all the ack_notifiers_ will
63 // be told which sequeunce numbers were ACKed.
64 // Once a given QuicAckNotifier has seen all the sequence numbers it is
65 // interested in, it will be deleted, and removed from this set.
66 // Owns the AckNotifiers in this set.
67 AckNotifierSet ack_notifiers_;
69 // Maps from sequence number to the AckNotifiers which are registered
70 // for that sequence number. On receipt of an ACK for a given sequence
71 // number, call OnAck for all mapped AckNotifiers.
72 // Does not own the AckNotifiers.
73 AckNotifierMap ack_notifier_map_;
76 } // namespace net
78 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_