Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> | |
| 9 #include <map> | 8 #include <map> |
| 10 #include <set> | 9 #include <set> |
| 11 | 10 |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/containers/hash_tables.h" | |
|
wtc
2013/10/01 14:06:59
Do we still need these two headers? It seems that
ramant (doing other things)
2013/10/01 22:29:32
Fixed the problem with hash_tables.h not compiling
| |
| 12 #include "net/quic/quic_protocol.h" | 13 #include "net/quic/quic_protocol.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 class QuicAckNotifier; | 17 class QuicAckNotifier; |
| 17 | 18 |
| 18 // The AckNotifierManager is used by the QuicConnection to keep track of all the | 19 // The AckNotifierManager is used by the QuicSentPacketManager to keep track of |
| 19 // AckNotifiers currently active. It owns the AckNotifiers which it gets from | 20 // all the AckNotifiers currently active. It owns the AckNotifiers which it gets |
| 20 // the serialized packets passed into OnSerializedPacket. It maintains both a | 21 // from the serialized packets passed into OnSerializedPacket. It maintains both |
| 21 // list of AckNotifiers and a map from sequence number to AckNotifier the sake | 22 // a list 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 // of efficiency - we can quickly check the map to see if any AckNotifiers are |
| 23 // interested in a given sequence number. | 24 // interested in a given sequence number. |
| 24 | 25 |
| 25 class NET_EXPORT_PRIVATE AckNotifierManager { | 26 class NET_EXPORT_PRIVATE AckNotifierManager { |
| 26 public: | 27 public: |
| 27 AckNotifierManager(); | 28 AckNotifierManager(); |
| 28 virtual ~AckNotifierManager(); | 29 virtual ~AckNotifierManager(); |
| 29 | 30 |
| 30 // Called from QuicConnection when it receives a new AckFrame. For each packet | 31 // Called when the connection receives a new AckFrame. For each packet |
| 31 // in |acked_packets|, if the packet sequence number exists in | 32 // in |acked_packets|, if the packet sequence number exists in |
| 32 // ack_notifier_map_ then the corresponding AckNotifiers will have their OnAck | 33 // ack_notifier_map_ then the corresponding AckNotifiers will have their OnAck |
| 33 // method called. | 34 // method called. |
| 34 void OnIncomingAck(const SequenceNumberSet& acked_packets); | 35 void OnIncomingAck(const SequenceNumberSet& acked_packets); |
| 35 | 36 |
| 36 // If a packet has been retransmitted with a new sequence number, then this | 37 // If a packet has been retransmitted with a new sequence number, then this |
| 37 // will be called. It updates the mapping in ack_notifier_map_, and also | 38 // will be called. It updates the mapping in ack_notifier_map_, and also |
| 38 // updates the internal list of sequence numbers in each matching AckNotifier. | 39 // updates the internal list of sequence numbers in each matching AckNotifier. |
| 39 void UpdateSequenceNumber(QuicPacketSequenceNumber old_sequence_number, | 40 void UpdateSequenceNumber(QuicPacketSequenceNumber old_sequence_number, |
| 40 QuicPacketSequenceNumber new_sequence_number); | 41 QuicPacketSequenceNumber new_sequence_number); |
| 41 | 42 |
| 42 // This is called after a packet has been serialized and is ready to be sent. | 43 // This is called after a packet has been serialized, is ready to be sent, and |
| 43 // If any of the frames in |serialized_packet| have AckNotifiers registered, | 44 // contains retransmittable frames (which may have associated AckNotifiers). |
| 44 // then add them to our internal map and additionally inform the AckNotifier | 45 // If any of the retransmittable frames included in |serialized_packet| have |
| 45 // of the sequence number which it should track. | 46 // AckNotifiers registered, then add them to our internal map and additionally |
| 47 // inform the AckNotifier of the sequence number which it should track. | |
| 46 void OnSerializedPacket(const SerializedPacket& serialized_packet); | 48 void OnSerializedPacket(const SerializedPacket& serialized_packet); |
| 47 | 49 |
| 48 // Called from QuicConnection when data is sent which the sender would like to | |
| 49 // be notified on receipt of all ACKs. Adds the |notifier| to our map. | |
| 50 void AddAckNotifier(QuicAckNotifier* notifier); | |
| 51 | |
| 52 private: | 50 private: |
| 53 typedef std::list<QuicAckNotifier*> AckNotifierList; | 51 // TODO(rtenneti): base::hash_set doesn't compile and is not fully supported |
| 52 // until C++11. | |
|
wtc
2013/10/01 14:06:59
Nit: this comment needs more context. I don't know
ramant (doing other things)
2013/10/01 22:29:32
Deleted the comment.
| |
| 54 typedef std::set<QuicAckNotifier*> AckNotifierSet; | 53 typedef std::set<QuicAckNotifier*> AckNotifierSet; |
| 55 typedef std::map<QuicPacketSequenceNumber, AckNotifierSet> AckNotifierMap; | 54 typedef std::map<QuicPacketSequenceNumber, AckNotifierSet> AckNotifierMap; |
| 56 | 55 |
| 57 // On every ACK frame received by this connection, all the ack_notifiers_ will | 56 // On every ACK frame received by the connection, all the ack_notifiers_ will |
| 58 // be told which sequeunce numbers were ACKed. | 57 // be told which sequeunce numbers were ACKed. |
| 59 // 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 |
| 60 // interested in, it will be deleted, and removed from this list. | 59 // interested in, it will be deleted, and removed from this list. |
| 61 // Owns the AckNotifiers in this list. | 60 // Owns the AckNotifiers in this list. |
|
wtc
2013/10/01 14:06:59
Nit: should we change all occurrences of "list" in
ramant (doing other things)
2013/10/01 22:29:32
Done.
| |
| 62 AckNotifierList ack_notifiers_; | 61 AckNotifierSet ack_notifiers_; |
| 63 | 62 |
| 64 // Maps from sequence number to the AckNotifiers which are registered | 63 // Maps from sequence number to the AckNotifiers which are registered |
| 65 // 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 |
| 66 // number, call OnAck for all mapped AckNotifiers. | 65 // number, call OnAck for all mapped AckNotifiers. |
| 67 // Does not own the AckNotifiers. | 66 // Does not own the AckNotifiers. |
| 68 std::map<QuicPacketSequenceNumber, AckNotifierSet> ack_notifier_map_; | 67 std::map<QuicPacketSequenceNumber, AckNotifierSet> ack_notifier_map_; |
|
wtc
2013/10/01 14:06:59
This is an AckNotifierMap:
AckNotifierMap ack_no
ramant (doing other things)
2013/10/01 22:29:32
Done.
| |
| 69 }; | 68 }; |
| 70 | 69 |
| 71 } // namespace net | 70 } // namespace net |
| 72 | 71 |
| 73 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_ | 72 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_MANAGER_H_ |
| OLD | NEW |