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

Side by Side Diff: net/quic/core/quic_unacked_packet_map.h

Issue 2547583002: Landing Recent QUIC changes until Fri Nov 18 23:21:04 2016 +0000 (Closed)
Patch Set: Remove explicit HTTP/2 enum usage Created 4 years 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/core/quic_types.h ('k') | net/quic/core/quic_unacked_packet_map.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_UNACKED_PACKET_MAP_H_ 5 #ifndef NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_
6 #define NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ 6 #define NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <deque> 10 #include <deque>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
14 #include "net/quic/core/quic_protocol.h" 14 #include "net/quic/core/quic_packets.h"
15 #include "net/quic/core/quic_transmission_info.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 // Class which tracks unacked packets for three purposes: 19 // Class which tracks unacked packets for three purposes:
19 // 1) Track retransmittable data, including multiple transmissions of frames. 20 // 1) Track retransmittable data, including multiple transmissions of frames.
20 // 2) Track packets and bytes in flight for congestion control. 21 // 2) Track packets and bytes in flight for congestion control.
21 // 3) Track sent time of packets to provide RTT measurements from acks. 22 // 3) Track sent time of packets to provide RTT measurements from acks.
22 class NET_EXPORT_PRIVATE QuicUnackedPacketMap { 23 class NET_EXPORT_PRIVATE QuicUnackedPacketMap {
23 public: 24 public:
24 QuicUnackedPacketMap(); 25 QuicUnackedPacketMap();
25 ~QuicUnackedPacketMap(); 26 ~QuicUnackedPacketMap();
26 27
27 // Adds |serialized_packet| to the map and marks it as sent at |sent_time|. 28 // Adds |serialized_packet| to the map and marks it as sent at |sent_time|.
28 // Marks the packet as in flight if |set_in_flight| is true. 29 // Marks the packet as in flight if |set_in_flight| is true.
29 // Packets marked as in flight are expected to be marked as missing when they 30 // Packets marked as in flight are expected to be marked as missing when they
30 // don't arrive, indicating the need for retransmission. 31 // don't arrive, indicating the need for retransmission.
31 // |old_packet_number| is the packet number of the previous transmission, 32 // |old_packet_number| is the packet number of the previous transmission,
32 // or 0 if there was none. 33 // or 0 if there was none.
33 // Any AckNotifierWrappers in |serialized_packet| are swapped from the 34 // Any AckNotifierWrappers in |serialized_packet| are swapped from the
34 // serialized packet into the TransmissionInfo. 35 // serialized packet into the QuicTransmissionInfo.
35 void AddSentPacket(SerializedPacket* serialized_packet, 36 void AddSentPacket(SerializedPacket* serialized_packet,
36 QuicPacketNumber old_packet_number, 37 QuicPacketNumber old_packet_number,
37 TransmissionType transmission_type, 38 TransmissionType transmission_type,
38 QuicTime sent_time, 39 QuicTime sent_time,
39 bool set_in_flight); 40 bool set_in_flight);
40 41
41 // Returns true if the packet |packet_number| is unacked. 42 // Returns true if the packet |packet_number| is unacked.
42 bool IsUnacked(QuicPacketNumber packet_number) const; 43 bool IsUnacked(QuicPacketNumber packet_number) const;
43 44
44 // Notifies all the AckListeners attached to the |info| and 45 // Notifies all the AckListeners attached to the |info| and
45 // clears them to ensure they're not notified again. 46 // clears them to ensure they're not notified again.
46 void NotifyAndClearListeners(std::list<AckListenerWrapper>* ack_listeners, 47 void NotifyAndClearListeners(std::list<AckListenerWrapper>* ack_listeners,
47 QuicTime::Delta delta_largest_observed); 48 QuicTime::Delta delta_largest_observed);
48 49
49 // Notifies all the AckListeners attached to |newest_transmission|. 50 // Notifies all the AckListeners attached to |newest_transmission|.
50 void NotifyAndClearListeners(QuicPacketNumber newest_transmission, 51 void NotifyAndClearListeners(QuicPacketNumber newest_transmission,
51 QuicTime::Delta delta_largest_observed); 52 QuicTime::Delta delta_largest_observed);
52 53
53 // Marks |info| as no longer in flight. 54 // Marks |info| as no longer in flight.
54 void RemoveFromInFlight(TransmissionInfo* info); 55 void RemoveFromInFlight(QuicTransmissionInfo* info);
55 56
56 // Marks |packet_number| as no longer in flight. 57 // Marks |packet_number| as no longer in flight.
57 void RemoveFromInFlight(QuicPacketNumber packet_number); 58 void RemoveFromInFlight(QuicPacketNumber packet_number);
58 59
59 // Marks |packet_number| as in flight. Must not be unackable. 60 // Marks |packet_number| as in flight. Must not be unackable.
60 void RestoreToInFlight(QuicPacketNumber packet_number); 61 void RestoreToInFlight(QuicPacketNumber packet_number);
61 62
62 // No longer retransmit data for |stream_id|. 63 // No longer retransmit data for |stream_id|.
63 void CancelRetransmissionsForStream(QuicStreamId stream_id); 64 void CancelRetransmissionsForStream(QuicStreamId stream_id);
64 65
(...skipping 22 matching lines...) Expand all
87 // Returns the largest packet number that has been acked. 88 // Returns the largest packet number that has been acked.
88 QuicPacketNumber largest_observed() const { return largest_observed_; } 89 QuicPacketNumber largest_observed() const { return largest_observed_; }
89 90
90 // Returns the sum of bytes from all packets in flight. 91 // Returns the sum of bytes from all packets in flight.
91 QuicByteCount bytes_in_flight() const { return bytes_in_flight_; } 92 QuicByteCount bytes_in_flight() const { return bytes_in_flight_; }
92 93
93 // Returns the smallest packet number of a serialized packet which has not 94 // Returns the smallest packet number of a serialized packet which has not
94 // been acked by the peer. If there are no unacked packets, returns 0. 95 // been acked by the peer. If there are no unacked packets, returns 0.
95 QuicPacketNumber GetLeastUnacked() const; 96 QuicPacketNumber GetLeastUnacked() const;
96 97
97 typedef std::deque<TransmissionInfo> UnackedPacketMap; 98 typedef std::deque<QuicTransmissionInfo> UnackedPacketMap;
98 99
99 typedef UnackedPacketMap::const_iterator const_iterator; 100 typedef UnackedPacketMap::const_iterator const_iterator;
100 typedef UnackedPacketMap::iterator iterator; 101 typedef UnackedPacketMap::iterator iterator;
101 102
102 const_iterator begin() const { return unacked_packets_.begin(); } 103 const_iterator begin() const { return unacked_packets_.begin(); }
103 const_iterator end() const { return unacked_packets_.end(); } 104 const_iterator end() const { return unacked_packets_.end(); }
104 iterator begin() { return unacked_packets_.begin(); } 105 iterator begin() { return unacked_packets_.begin(); }
105 iterator end() { return unacked_packets_.end(); } 106 iterator end() { return unacked_packets_.end(); }
106 107
107 // Returns true if there are unacked packets that are in flight. 108 // Returns true if there are unacked packets that are in flight.
108 bool HasInFlightPackets() const; 109 bool HasInFlightPackets() const;
109 110
110 // Returns the TransmissionInfo associated with |packet_number|, which 111 // Returns the QuicTransmissionInfo associated with |packet_number|, which
111 // must be unacked. 112 // must be unacked.
112 const TransmissionInfo& GetTransmissionInfo( 113 const QuicTransmissionInfo& GetTransmissionInfo(
113 QuicPacketNumber packet_number) const; 114 QuicPacketNumber packet_number) const;
114 115
115 // Returns mutable TransmissionInfo associated with |packet_number|, which 116 // Returns mutable QuicTransmissionInfo associated with |packet_number|, which
116 // must be unacked. 117 // must be unacked.
117 TransmissionInfo* GetMutableTransmissionInfo(QuicPacketNumber packet_number); 118 QuicTransmissionInfo* GetMutableTransmissionInfo(
119 QuicPacketNumber packet_number);
118 120
119 // Returns the time that the last unacked packet was sent. 121 // Returns the time that the last unacked packet was sent.
120 QuicTime GetLastPacketSentTime() const; 122 QuicTime GetLastPacketSentTime() const;
121 123
122 // Returns the number of unacked packets. 124 // Returns the number of unacked packets.
123 size_t GetNumUnackedPacketsDebugOnly() const; 125 size_t GetNumUnackedPacketsDebugOnly() const;
124 126
125 // Returns true if there are multiple packets in flight. 127 // Returns true if there are multiple packets in flight.
126 bool HasMultipleInFlightPackets() const; 128 bool HasMultipleInFlightPackets() const;
127 129
128 // Returns true if there are any pending crypto packets. 130 // Returns true if there are any pending crypto packets.
129 bool HasPendingCryptoPackets() const; 131 bool HasPendingCryptoPackets() const;
130 132
131 // Removes any retransmittable frames from this transmission or an associated 133 // Removes any retransmittable frames from this transmission or an associated
132 // transmission. It removes now useless transmissions, and disconnects any 134 // transmission. It removes now useless transmissions, and disconnects any
133 // other packets from other transmissions. 135 // other packets from other transmissions.
134 void RemoveRetransmittability(TransmissionInfo* info); 136 void RemoveRetransmittability(QuicTransmissionInfo* info);
135 137
136 // Looks up the TransmissionInfo by |packet_number| and calls 138 // Looks up the QuicTransmissionInfo by |packet_number| and calls
137 // RemoveRetransmittability. 139 // RemoveRetransmittability.
138 void RemoveRetransmittability(QuicPacketNumber packet_number); 140 void RemoveRetransmittability(QuicPacketNumber packet_number);
139 141
140 // Increases the largest observed. Any packets less or equal to 142 // Increases the largest observed. Any packets less or equal to
141 // |largest_acked_packet| are discarded if they are only for the RTT purposes. 143 // |largest_acked_packet| are discarded if they are only for the RTT purposes.
142 void IncreaseLargestObserved(QuicPacketNumber largest_observed); 144 void IncreaseLargestObserved(QuicPacketNumber largest_observed);
143 145
144 // Remove any packets no longer needed for retransmission, congestion, or 146 // Remove any packets no longer needed for retransmission, congestion, or
145 // RTT measurement purposes. 147 // RTT measurement purposes.
146 void RemoveObsoletePackets(); 148 void RemoveObsoletePackets();
147 149
148 private: 150 private:
149 // Called when a packet is retransmitted with a new packet number. 151 // Called when a packet is retransmitted with a new packet number.
150 // |old_packet_number| will remain unacked, but will have no 152 // |old_packet_number| will remain unacked, but will have no
151 // retransmittable data associated with it. Retransmittable frames will be 153 // retransmittable data associated with it. Retransmittable frames will be
152 // transferred to |info| and all_transmissions will be populated. 154 // transferred to |info| and all_transmissions will be populated.
153 void TransferRetransmissionInfo(QuicPacketNumber old_packet_number, 155 void TransferRetransmissionInfo(QuicPacketNumber old_packet_number,
154 QuicPacketNumber new_packet_number, 156 QuicPacketNumber new_packet_number,
155 TransmissionType transmission_type, 157 TransmissionType transmission_type,
156 TransmissionInfo* info); 158 QuicTransmissionInfo* info);
157
158 void MaybeRemoveRetransmittableFrames(TransmissionInfo* transmission_info);
159 159
160 // Returns true if packet may be useful for an RTT measurement. 160 // Returns true if packet may be useful for an RTT measurement.
161 bool IsPacketUsefulForMeasuringRtt(QuicPacketNumber packet_number, 161 bool IsPacketUsefulForMeasuringRtt(QuicPacketNumber packet_number,
162 const TransmissionInfo& info) const; 162 const QuicTransmissionInfo& info) const;
163 163
164 // Returns true if packet may be useful for congestion control purposes. 164 // Returns true if packet may be useful for congestion control purposes.
165 bool IsPacketUsefulForCongestionControl(const TransmissionInfo& info) const; 165 bool IsPacketUsefulForCongestionControl(
166 const QuicTransmissionInfo& info) const;
166 167
167 // Returns true if packet may be associated with retransmittable data 168 // Returns true if packet may be associated with retransmittable data
168 // directly or through retransmissions. 169 // directly or through retransmissions.
169 bool IsPacketUsefulForRetransmittableData(const TransmissionInfo& info) const; 170 bool IsPacketUsefulForRetransmittableData(
171 const QuicTransmissionInfo& info) const;
170 172
171 // Returns true if the packet no longer has a purpose in the map. 173 // Returns true if the packet no longer has a purpose in the map.
172 bool IsPacketUseless(QuicPacketNumber packet_number, 174 bool IsPacketUseless(QuicPacketNumber packet_number,
173 const TransmissionInfo& info) const; 175 const QuicTransmissionInfo& info) const;
174 176
175 QuicPacketNumber largest_sent_packet_; 177 QuicPacketNumber largest_sent_packet_;
176 // The largest sent packet we expect to receive an ack for. 178 // The largest sent packet we expect to receive an ack for.
177 QuicPacketNumber largest_sent_retransmittable_packet_; 179 QuicPacketNumber largest_sent_retransmittable_packet_;
178 QuicPacketNumber largest_observed_; 180 QuicPacketNumber largest_observed_;
179 181
180 // Newly serialized retransmittable packets are added to this map, which 182 // Newly serialized retransmittable packets are added to this map, which
181 // contains owning pointers to any contained frames. If a packet is 183 // contains owning pointers to any contained frames. If a packet is
182 // retransmitted, this map will contain entries for both the old and the new 184 // retransmitted, this map will contain entries for both the old and the new
183 // packet. The old packet's retransmittable frames entry will be nullptr, 185 // packet. The old packet's retransmittable frames entry will be nullptr,
184 // while the new packet's entry will contain the frames to retransmit. 186 // while the new packet's entry will contain the frames to retransmit.
185 // If the old packet is acked before the new packet, then the old entry will 187 // If the old packet is acked before the new packet, then the old entry will
186 // be removed from the map and the new entry's retransmittable frames will be 188 // be removed from the map and the new entry's retransmittable frames will be
187 // set to nullptr. 189 // set to nullptr.
188 UnackedPacketMap unacked_packets_; 190 UnackedPacketMap unacked_packets_;
189 // The packet at the 0th index of unacked_packets_. 191 // The packet at the 0th index of unacked_packets_.
190 QuicPacketNumber least_unacked_; 192 QuicPacketNumber least_unacked_;
191 193
192 QuicByteCount bytes_in_flight_; 194 QuicByteCount bytes_in_flight_;
193 // Number of retransmittable crypto handshake packets. 195 // Number of retransmittable crypto handshake packets.
194 size_t pending_crypto_packet_count_; 196 size_t pending_crypto_packet_count_;
195 197
196 DISALLOW_COPY_AND_ASSIGN(QuicUnackedPacketMap); 198 DISALLOW_COPY_AND_ASSIGN(QuicUnackedPacketMap);
197 }; 199 };
198 200
199 } // namespace net 201 } // namespace net
200 202
201 #endif // NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ 203 #endif // NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_
OLDNEW
« no previous file with comments | « net/quic/core/quic_types.h ('k') | net/quic/core/quic_unacked_packet_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698