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

Side by Side Diff: net/quic/quic_unacked_packet_map.cc

Issue 302783003: Rename QUIC's TransmissionInfo pending to in_flight and the associated (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/quic_unacked_packet_map.h ('k') | net/quic/quic_unacked_packet_map_test.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 #include "net/quic/quic_unacked_packet_map.h" 5 #include "net/quic/quic_unacked_packet_map.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/quic/quic_connection_stats.h" 9 #include "net/quic/quic_connection_stats.h"
10 #include "net/quic/quic_utils_chromium.h" 10 #include "net/quic/quic_utils_chromium.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 TransmissionInfo(frames, 77 TransmissionInfo(frames,
78 new_sequence_number, 78 new_sequence_number,
79 transmission_info->sequence_number_length, 79 transmission_info->sequence_number_length,
80 transmission_info->all_transmissions); 80 transmission_info->all_transmissions);
81 } 81 }
82 82
83 void QuicUnackedPacketMap::ClearPreviousRetransmissions(size_t num_to_clear) { 83 void QuicUnackedPacketMap::ClearPreviousRetransmissions(size_t num_to_clear) {
84 UnackedPacketMap::iterator it = unacked_packets_.begin(); 84 UnackedPacketMap::iterator it = unacked_packets_.begin();
85 while (it != unacked_packets_.end() && num_to_clear > 0) { 85 while (it != unacked_packets_.end() && num_to_clear > 0) {
86 QuicPacketSequenceNumber sequence_number = it->first; 86 QuicPacketSequenceNumber sequence_number = it->first;
87 // If this is a pending packet, or has retransmittable data, then there is 87 // If this packet is in flight, or has retransmittable data, then there is
88 // no point in clearing out any further packets, because they would not 88 // no point in clearing out any further packets, because they would not
89 // affect the high water mark. 89 // affect the high water mark.
90 if (it->second.pending || it->second.retransmittable_frames != NULL) { 90 if (it->second.in_flight || it->second.retransmittable_frames != NULL) {
91 break; 91 break;
92 } 92 }
93 93
94 it->second.all_transmissions->erase(sequence_number); 94 it->second.all_transmissions->erase(sequence_number);
95 LOG_IF(DFATAL, it->second.all_transmissions->empty()) 95 LOG_IF(DFATAL, it->second.all_transmissions->empty())
96 << "Previous retransmissions must have a newer transmission."; 96 << "Previous retransmissions must have a newer transmission.";
97 ++it; 97 ++it;
98 unacked_packets_.erase(sequence_number); 98 unacked_packets_.erase(sequence_number);
99 --num_to_clear; 99 --num_to_clear;
100 } 100 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // frames associated with this packet. 136 // frames associated with this packet.
137 for (SequenceNumberSet::reverse_iterator it = all_transmissions->rbegin(); 137 for (SequenceNumberSet::reverse_iterator it = all_transmissions->rbegin();
138 it != all_transmissions->rend(); ++it) { 138 it != all_transmissions->rend(); ++it) {
139 TransmissionInfo* transmission_info = FindOrNull(unacked_packets_, *it); 139 TransmissionInfo* transmission_info = FindOrNull(unacked_packets_, *it);
140 if (transmission_info == NULL) { 140 if (transmission_info == NULL) {
141 LOG(DFATAL) << "All transmissions in all_transmissions must be present " 141 LOG(DFATAL) << "All transmissions in all_transmissions must be present "
142 << "in the unacked packet map."; 142 << "in the unacked packet map.";
143 continue; 143 continue;
144 } 144 }
145 MaybeRemoveRetransmittableFrames(transmission_info); 145 MaybeRemoveRetransmittableFrames(transmission_info);
146 if (*it <= largest_observed_ && !transmission_info->pending) { 146 if (*it <= largest_observed_ && !transmission_info->in_flight) {
147 unacked_packets_.erase(*it); 147 unacked_packets_.erase(*it);
148 } else { 148 } else {
149 transmission_info->all_transmissions = new SequenceNumberSet(); 149 transmission_info->all_transmissions = new SequenceNumberSet();
150 transmission_info->all_transmissions->insert(*it); 150 transmission_info->all_transmissions->insert(*it);
151 } 151 }
152 } 152 }
153 153
154 delete all_transmissions; 154 delete all_transmissions;
155 } 155 }
156 156
(...skipping 20 matching lines...) Expand all
177 continue; 177 continue;
178 } 178 }
179 delete it->second.all_transmissions; 179 delete it->second.all_transmissions;
180 QuicPacketSequenceNumber sequence_number = it->first; 180 QuicPacketSequenceNumber sequence_number = it->first;
181 ++it; 181 ++it;
182 unacked_packets_.erase(sequence_number); 182 unacked_packets_.erase(sequence_number);
183 } 183 }
184 } 184 }
185 185
186 bool QuicUnackedPacketMap::IsPacketUseless( 186 bool QuicUnackedPacketMap::IsPacketUseless(
187 UnackedPacketMap::const_iterator it) { 187 UnackedPacketMap::const_iterator it) const {
188 return it->first <= largest_observed_ && 188 return it->first <= largest_observed_ &&
189 !it->second.pending && 189 !it->second.in_flight &&
190 it->second.retransmittable_frames == NULL && 190 it->second.retransmittable_frames == NULL &&
191 it->second.all_transmissions->size() == 1; 191 it->second.all_transmissions->size() == 1;
192 } 192 }
193 193
194 bool QuicUnackedPacketMap::IsUnacked( 194 bool QuicUnackedPacketMap::IsUnacked(
195 QuicPacketSequenceNumber sequence_number) const { 195 QuicPacketSequenceNumber sequence_number) const {
196 return ContainsKey(unacked_packets_, sequence_number); 196 return ContainsKey(unacked_packets_, sequence_number);
197 } 197 }
198 198
199 void QuicUnackedPacketMap::SetNotPending( 199 void QuicUnackedPacketMap::RemoveFromInFlight(
200 QuicPacketSequenceNumber sequence_number) { 200 QuicPacketSequenceNumber sequence_number) {
201 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number); 201 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
202 if (it == unacked_packets_.end()) { 202 if (it == unacked_packets_.end()) {
203 LOG(DFATAL) << "SetNotPending called for packet that is not unacked: " 203 LOG(DFATAL) << "RemoveFromFlight called for packet that is not unacked: "
204 << sequence_number; 204 << sequence_number;
205 return; 205 return;
206 } 206 }
207 if (it->second.pending) { 207 if (it->second.in_flight) {
208 LOG_IF(DFATAL, bytes_in_flight_ < it->second.bytes_sent); 208 LOG_IF(DFATAL, bytes_in_flight_ < it->second.bytes_sent);
209 bytes_in_flight_ -= it->second.bytes_sent; 209 bytes_in_flight_ -= it->second.bytes_sent;
210 it->second.pending = false; 210 it->second.in_flight = false;
211 } 211 }
212 if (IsPacketUseless(it)) { 212 if (IsPacketUseless(it)) {
213 delete it->second.all_transmissions; 213 delete it->second.all_transmissions;
214 unacked_packets_.erase(it); 214 unacked_packets_.erase(it);
215 } 215 }
216 } 216 }
217 217
218 bool QuicUnackedPacketMap::HasUnackedPackets() const { 218 bool QuicUnackedPacketMap::HasUnackedPackets() const {
219 return !unacked_packets_.empty(); 219 return !unacked_packets_.empty();
220 } 220 }
221 221
222 bool QuicUnackedPacketMap::HasPendingPackets() const { 222 bool QuicUnackedPacketMap::HasInFlightPackets() const {
223 return bytes_in_flight_ > 0; 223 return bytes_in_flight_ > 0;
224 } 224 }
225 225
226 const TransmissionInfo& QuicUnackedPacketMap::GetTransmissionInfo( 226 const TransmissionInfo& QuicUnackedPacketMap::GetTransmissionInfo(
227 QuicPacketSequenceNumber sequence_number) const { 227 QuicPacketSequenceNumber sequence_number) const {
228 return unacked_packets_.find(sequence_number)->second; 228 return unacked_packets_.find(sequence_number)->second;
229 } 229 }
230 230
231 QuicTime QuicUnackedPacketMap::GetLastPacketSentTime() const { 231 QuicTime QuicUnackedPacketMap::GetLastPacketSentTime() const {
232 UnackedPacketMap::const_reverse_iterator it = unacked_packets_.rbegin(); 232 UnackedPacketMap::const_reverse_iterator it = unacked_packets_.rbegin();
233 while (it != unacked_packets_.rend()) { 233 while (it != unacked_packets_.rend()) {
234 if (it->second.pending) { 234 if (it->second.in_flight) {
235 LOG_IF(DFATAL, it->second.sent_time == QuicTime::Zero()) 235 LOG_IF(DFATAL, it->second.sent_time == QuicTime::Zero())
236 << "Sent time can never be zero for a pending packet."; 236 << "Sent time can never be zero for a packet in flight.";
237 return it->second.sent_time; 237 return it->second.sent_time;
238 } 238 }
239 ++it; 239 ++it;
240 } 240 }
241 LOG(DFATAL) << "Unable to find sent time. " 241 LOG(DFATAL) << "GetLastPacketSentTime requires in flight packets.";
242 << "This method is only intended when there are pending packets.";
243 return QuicTime::Zero(); 242 return QuicTime::Zero();
244 } 243 }
245 244
246 QuicTime QuicUnackedPacketMap::GetFirstPendingPacketSentTime() const { 245 QuicTime QuicUnackedPacketMap::GetFirstInFlightPacketSentTime() const {
247 UnackedPacketMap::const_iterator it = unacked_packets_.begin(); 246 UnackedPacketMap::const_iterator it = unacked_packets_.begin();
248 while (it != unacked_packets_.end() && !it->second.pending) { 247 while (it != unacked_packets_.end() && !it->second.in_flight) {
249 ++it; 248 ++it;
250 } 249 }
251 if (it == unacked_packets_.end()) { 250 if (it == unacked_packets_.end()) {
252 LOG(DFATAL) << "No pending packets"; 251 LOG(DFATAL) << "GetFirstInFlightPacketSentTime requires in flight packets.";
253 return QuicTime::Zero(); 252 return QuicTime::Zero();
254 } 253 }
255 return it->second.sent_time; 254 return it->second.sent_time;
256 } 255 }
257 256
258 size_t QuicUnackedPacketMap::GetNumUnackedPackets() const { 257 size_t QuicUnackedPacketMap::GetNumUnackedPackets() const {
259 return unacked_packets_.size(); 258 return unacked_packets_.size();
260 } 259 }
261 260
262 bool QuicUnackedPacketMap::HasMultiplePendingPackets() const { 261 bool QuicUnackedPacketMap::HasMultipleInFlightPackets() const {
263 size_t num_pending = 0; 262 size_t num_in_flight = 0;
264 for (UnackedPacketMap::const_reverse_iterator it = unacked_packets_.rbegin(); 263 for (UnackedPacketMap::const_reverse_iterator it = unacked_packets_.rbegin();
265 it != unacked_packets_.rend(); ++it) { 264 it != unacked_packets_.rend(); ++it) {
266 if (it->second.pending) { 265 if (it->second.in_flight) {
267 ++num_pending; 266 ++num_in_flight;
268 } 267 }
269 if (num_pending > 1) { 268 if (num_in_flight > 1) {
270 return true; 269 return true;
271 } 270 }
272 } 271 }
273 return false; 272 return false;
274 } 273 }
275 274
276 bool QuicUnackedPacketMap::HasPendingCryptoPackets() const { 275 bool QuicUnackedPacketMap::HasPendingCryptoPackets() const {
277 return pending_crypto_packet_count_ > 0; 276 return pending_crypto_packet_count_ > 0;
278 } 277 }
279 278
280 bool QuicUnackedPacketMap::HasUnackedRetransmittableFrames() const { 279 bool QuicUnackedPacketMap::HasUnackedRetransmittableFrames() const {
281 for (UnackedPacketMap::const_reverse_iterator it = 280 for (UnackedPacketMap::const_reverse_iterator it =
282 unacked_packets_.rbegin(); it != unacked_packets_.rend(); ++it) { 281 unacked_packets_.rbegin(); it != unacked_packets_.rend(); ++it) {
283 if (it->second.pending && it->second.retransmittable_frames) { 282 if (it->second.in_flight && it->second.retransmittable_frames) {
284 return true; 283 return true;
285 } 284 }
286 } 285 }
287 return false; 286 return false;
288 } 287 }
289 288
290 QuicPacketSequenceNumber 289 QuicPacketSequenceNumber
291 QuicUnackedPacketMap::GetLeastUnackedSentPacket() const { 290 QuicUnackedPacketMap::GetLeastUnackedSentPacket() const {
292 if (unacked_packets_.empty()) { 291 if (unacked_packets_.empty()) {
293 // If there are no unacked packets, return 0. 292 // If there are no unacked packets, return 0.
294 return 0; 293 return 0;
295 } 294 }
296 295
297 return unacked_packets_.begin()->first; 296 return unacked_packets_.begin()->first;
298 } 297 }
299 298
300 void QuicUnackedPacketMap::SetSent(QuicPacketSequenceNumber sequence_number, 299 void QuicUnackedPacketMap::SetSent(QuicPacketSequenceNumber sequence_number,
301 QuicTime sent_time, 300 QuicTime sent_time,
302 QuicByteCount bytes_sent, 301 QuicByteCount bytes_sent,
303 bool set_pending) { 302 bool set_in_flight) {
304 DCHECK_LT(0u, sequence_number); 303 DCHECK_LT(0u, sequence_number);
305 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number); 304 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
306 if (it == unacked_packets_.end()) { 305 if (it == unacked_packets_.end()) {
307 LOG(DFATAL) << "OnPacketSent called for packet that is not unacked: " 306 LOG(DFATAL) << "OnPacketSent called for packet that is not unacked: "
308 << sequence_number; 307 << sequence_number;
309 return; 308 return;
310 } 309 }
311 DCHECK(!it->second.pending); 310 DCHECK(!it->second.in_flight);
312 311
313 largest_sent_packet_ = max(sequence_number, largest_sent_packet_); 312 largest_sent_packet_ = max(sequence_number, largest_sent_packet_);
314 it->second.sent_time = sent_time; 313 it->second.sent_time = sent_time;
315 if (set_pending) { 314 if (set_in_flight) {
316 bytes_in_flight_ += bytes_sent; 315 bytes_in_flight_ += bytes_sent;
317 it->second.bytes_sent = bytes_sent; 316 it->second.bytes_sent = bytes_sent;
318 it->second.pending = true; 317 it->second.in_flight = true;
319 } 318 }
320 } 319 }
321 320
322 } // namespace net 321 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_unacked_packet_map.h ('k') | net/quic/quic_unacked_packet_map_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698