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

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

Issue 198353003: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/congestion_control/cubic_test.cc ('k') | net/quic/quic_ack_notifier.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_H_ 5 #ifndef NET_QUIC_QUIC_ACK_NOTIFIER_H_
6 #define NET_QUIC_QUIC_ACK_NOTIFIER_H_ 6 #define NET_QUIC_QUIC_ACK_NOTIFIER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "net/quic/quic_protocol.h" 9 #include "net/quic/quic_protocol.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 // Used to register with a QuicConnection for notification once a set of packets 13 // Used to register with a QuicConnection for notification once a set of packets
14 // have all been ACKed. 14 // have all been ACKed.
15 // The connection informs this class of newly ACKed sequence numbers, and once 15 // The connection informs this class of newly ACKed sequence numbers, and once
16 // we have seen ACKs for all the sequence numbers we are interested in, we 16 // we have seen ACKs for all the sequence numbers we are interested in, we
17 // trigger a call to a provided Closure. 17 // trigger a call to a provided Closure.
18 class NET_EXPORT_PRIVATE QuicAckNotifier { 18 class NET_EXPORT_PRIVATE QuicAckNotifier {
19 public: 19 public:
20 class NET_EXPORT_PRIVATE DelegateInterface 20 class NET_EXPORT_PRIVATE DelegateInterface
21 : public base::RefCounted<DelegateInterface> { 21 : public base::RefCounted<DelegateInterface> {
22 public: 22 public:
23 DelegateInterface(); 23 DelegateInterface();
24 virtual void OnAckNotification() = 0; 24 // Args:
25 25 // num_original_packets - Number of packets in the original transmission.
26 // num_original_bytes - Number of packets in the original transmission.
27 // num_retransmitted_packets - Number of packets that had to be
28 // retransmitted.
29 // num_retransmitted_bytes - Number of bytes that had to be retransmitted.
30 virtual void OnAckNotification(int num_original_packets,
31 int num_original_bytes,
32 int num_retransmitted_packets,
33 int num_retransmitted_bytes) = 0;
26 protected: 34 protected:
27 friend class base::RefCounted<DelegateInterface>; 35 friend class base::RefCounted<DelegateInterface>;
28 36
29 // Delegates are ref counted. 37 // Delegates are ref counted.
30 virtual ~DelegateInterface(); 38 virtual ~DelegateInterface();
31 }; 39 };
32 40
33 // QuicAckNotifier is expected to keep its own reference to the delegate. 41 // QuicAckNotifier is expected to keep its own reference to the delegate.
34 explicit QuicAckNotifier(DelegateInterface* delegate); 42 explicit QuicAckNotifier(DelegateInterface* delegate);
35 virtual ~QuicAckNotifier(); 43 virtual ~QuicAckNotifier();
36 44
37 // Register a sequence number that this AckNotifier should be interested in. 45 // Register a sequence number that this AckNotifier should be interested in.
38 void AddSequenceNumber(const QuicPacketSequenceNumber& sequence_number); 46 void AddSequenceNumber(const QuicPacketSequenceNumber& sequence_number,
39 47 int packet_payload_size);
40 // Register a set of sequence numbers that this AckNotifier should be
41 // interested in.
42 void AddSequenceNumbers(const SequenceNumberSet& sequence_numbers);
43 48
44 // Called by the QuicConnection on receipt of new ACK frame, with the sequence 49 // Called by the QuicConnection on receipt of new ACK frame, with the sequence
45 // number referenced by the ACK frame. 50 // number referenced by the ACK frame.
46 // Deletes the matching sequence number from the stored set of sequence 51 // Deletes the matching sequence number from the stored set of sequence
47 // numbers. If this set is now empty, call the stored delegate's 52 // numbers. If this set is now empty, call the stored delegate's
48 // OnAckNotification method. 53 // OnAckNotification method.
49 // 54 //
50 // Returns true if the provided sequence_number caused the delegate to be 55 // Returns true if the provided sequence_number caused the delegate to be
51 // called, false otherwise. 56 // called, false otherwise.
52 bool OnAck(QuicPacketSequenceNumber sequence_number); 57 bool OnAck(QuicPacketSequenceNumber sequence_number);
53 58
54 bool IsEmpty() { return sequence_numbers_.empty(); } 59 bool IsEmpty() { return sequence_numbers_.empty(); }
55 60
56 // If a packet is retransmitted by the connection it will be sent with a 61 // If a packet is retransmitted by the connection it will be sent with a
57 // different sequence number. Updates our internal set of sequence_numbers to 62 // different sequence number. Updates our internal set of sequence_numbers to
58 // track the latest number. 63 // track the latest number.
59 void UpdateSequenceNumber(QuicPacketSequenceNumber old_sequence_number, 64 void UpdateSequenceNumber(QuicPacketSequenceNumber old_sequence_number,
60 QuicPacketSequenceNumber new_sequence_number); 65 QuicPacketSequenceNumber new_sequence_number);
61 66
62 private: 67 private:
68 struct PacketInfo {
69 PacketInfo();
70 explicit PacketInfo(int payload_size);
71
72 int packet_payload_size;
73 };
74
63 // The delegate's OnAckNotification() method will be called once we have been 75 // The delegate's OnAckNotification() method will be called once we have been
64 // notified of ACKs for all the sequence numbers we are tracking. 76 // notified of ACKs for all the sequence numbers we are tracking.
65 // This is not owned by OnAckNotifier and must outlive it. 77 // This is not owned by OnAckNotifier and must outlive it.
66 scoped_refptr<DelegateInterface> delegate_; 78 scoped_refptr<DelegateInterface> delegate_;
67 79
68 // Set of sequence numbers this notifier is waiting to hear about. The 80 // Sequence numbers this notifier is waiting to hear about. The
69 // delegate will not be called until this is an empty set. 81 // delegate will not be called until this is empty.
70 SequenceNumberSet sequence_numbers_; 82 base::hash_map<QuicPacketSequenceNumber, PacketInfo> sequence_numbers_;
83
84 // Transmission and retransmission stats.
85 // Number of packets in the original transmission.
86 int original_packet_count_;
87 // Number of packets in the original transmission.
88 int original_byte_count_;
89 // Number of packets that had to be retransmitted.
90 int retransmitted_packet_count_;
91 // Number of bytes that had to be retransmitted.
92 int retransmitted_byte_count_;
71 }; 93 };
72 94
73 }; // namespace net 95 }; // namespace net
74 96
75 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_H_ 97 #endif // NET_QUIC_QUIC_ACK_NOTIFIER_H_
OLDNEW
« no previous file with comments | « net/quic/congestion_control/cubic_test.cc ('k') | net/quic/quic_ack_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698