Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: net/quic/quic_ack_notifier_manager.h

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_ack_notifier.cc ('k') | net/quic/quic_ack_notifier_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_ 5 #ifndef NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_
6 #define NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_ 6 #define NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_
7 7
8 #include <list>
8 #include <map> 9 #include <map>
9 10
10 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
11 #include "net/quic/quic_protocol.h" 12 #include "net/quic/quic_protocol.h"
12 13
13 namespace net { 14 namespace net {
14 15
15 class QuicAckNotifier; 16 class QuicAckNotifier;
16 17
17 // The AckNotifierManager is used by the QuicSentPacketManager to keep track of 18 // 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 // all the AckNotifiers currently active. It owns the AckNotifiers which it gets
19 // from the serialized packets passed into OnSerializedPacket. It maintains both 20 // 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 // 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 // of efficiency - we can quickly check the map to see if any AckNotifiers are
22 // interested in a given sequence number. 23 // interested in a given sequence number.
23 class NET_EXPORT_PRIVATE AckNotifierManager { 24 class NET_EXPORT_PRIVATE AckNotifierManager {
24 public: 25 public:
25 AckNotifierManager(); 26 AckNotifierManager();
26 virtual ~AckNotifierManager(); 27 virtual ~AckNotifierManager();
27 28
28 // Called when the connection receives a new AckFrame. If |sequence_number| 29 // Called when the connection receives a new AckFrame. If |sequence_number|
29 // exists in ack_notifier_map_ then the corresponding AckNotifiers will have 30 // exists in ack_notifier_map_ then the corresponding AckNotifiers will have
30 // their OnAck method called. 31 // their OnAck method called.
31 void OnPacketAcked(QuicPacketSequenceNumber sequence_number, 32 void OnPacketAcked(QuicPacketSequenceNumber sequence_number,
32 QuicTime::Delta delta_largest_observed); 33 QuicTime::Delta delta_largest_observed);
33 34
34 // If a packet has been retransmitted with a new sequence number, then this 35 // 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 // 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 // updates the internal set of sequence numbers in each matching AckNotifier.
37 void UpdateSequenceNumber(QuicPacketSequenceNumber old_sequence_number, 38 void OnPacketRetransmitted(QuicPacketSequenceNumber old_sequence_number,
38 QuicPacketSequenceNumber new_sequence_number); 39 QuicPacketSequenceNumber new_sequence_number,
40 int packet_payload_size);
39 41
40 // This is called after a packet has been serialized, is ready to be sent, and 42 // This is called after a packet has been serialized, is ready to be sent, and
41 // contains retransmittable frames (which may have associated AckNotifiers). 43 // contains retransmittable frames (which may have associated AckNotifiers).
42 // If any of the retransmittable frames included in |serialized_packet| have 44 // If any of the retransmittable frames included in |serialized_packet| have
43 // AckNotifiers registered, then add them to our internal map and additionally 45 // AckNotifiers registered, then add them to our internal map and additionally
44 // inform the AckNotifier of the sequence number which it should track. 46 // inform the AckNotifier of the sequence number which it should track.
45 void OnSerializedPacket(const SerializedPacket& serialized_packet); 47 void OnSerializedPacket(const SerializedPacket& serialized_packet);
46 48
47 private: 49 private:
50 typedef std::list<QuicAckNotifier*> AckNotifierList;
48 typedef base::hash_set<QuicAckNotifier*> AckNotifierSet; 51 typedef base::hash_set<QuicAckNotifier*> AckNotifierSet;
49 typedef std::map<QuicPacketSequenceNumber, AckNotifierSet> AckNotifierMap; 52 // TODO(ianswett): Further improvement may come from changing this to a deque.
53 typedef base::hash_map<QuicPacketSequenceNumber, AckNotifierList>
54 AckNotifierMap;
50 55
51 // On every ACK frame received by the connection, all the ack_notifiers_ will 56 // On every ACK frame received by the connection, all the ack_notifiers_ will
52 // be told which sequeunce numbers were ACKed. 57 // be told which sequeunce numbers were ACKed.
53 // Once a given QuicAckNotifier has seen all the sequence numbers it is 58 // Once a given QuicAckNotifier has seen all the sequence numbers it is
54 // interested in, it will be deleted, and removed from this set. 59 // interested in, it will be deleted, and removed from this set.
55 // Owns the AckNotifiers in this set. 60 // Owns the AckNotifiers in this set.
56 AckNotifierSet ack_notifiers_; 61 AckNotifierSet ack_notifiers_;
57 62
58 // Maps from sequence number to the AckNotifiers which are registered 63 // Maps from sequence number to the AckNotifiers which are registered
59 // for that sequence number. On receipt of an ACK for a given sequence 64 // for that sequence number. On receipt of an ACK for a given sequence
60 // number, call OnAck for all mapped AckNotifiers. 65 // number, call OnAck for all mapped AckNotifiers.
61 // Does not own the AckNotifiers. 66 // Does not own the AckNotifiers.
62 AckNotifierMap ack_notifier_map_; 67 AckNotifierMap ack_notifier_map_;
63 68
64 DISALLOW_COPY_AND_ASSIGN(AckNotifierManager); 69 DISALLOW_COPY_AND_ASSIGN(AckNotifierManager);
65 }; 70 };
66 71
67 } // namespace net 72 } // namespace net
68 73
69 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_ 74 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_
OLDNEW
« no previous file with comments | « net/quic/quic_ack_notifier.cc ('k') | net/quic/quic_ack_notifier_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698