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

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

Issue 551223002: Discard old packets from the QuicSentPacketManager which are only (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_flaky_test_74798317
Patch Set: Created 6 years, 3 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_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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 serialized_packet.sequence_number_length)); 45 serialized_packet.sequence_number_length));
46 if (serialized_packet.retransmittable_frames != NULL && 46 if (serialized_packet.retransmittable_frames != NULL &&
47 serialized_packet.retransmittable_frames->HasCryptoHandshake() 47 serialized_packet.retransmittable_frames->HasCryptoHandshake()
48 == IS_HANDSHAKE) { 48 == IS_HANDSHAKE) {
49 ++pending_crypto_packet_count_; 49 ++pending_crypto_packet_count_;
50 } 50 }
51 } 51 }
52 52
53 void QuicUnackedPacketMap::RemoveObsoletePackets() { 53 void QuicUnackedPacketMap::RemoveObsoletePackets() {
54 while (!unacked_packets_.empty()) { 54 while (!unacked_packets_.empty()) {
55 if (!IsPacketUseless(least_unacked_, unacked_packets_.front())) { 55 if (!IsPacketRemovable(least_unacked_, unacked_packets_.front())) {
56 break; 56 break;
57 } 57 }
58 delete unacked_packets_.front().all_transmissions; 58 delete unacked_packets_.front().all_transmissions;
59 unacked_packets_.pop_front(); 59 unacked_packets_.pop_front();
60 ++least_unacked_; 60 ++least_unacked_;
61 } 61 }
62 } 62 }
63 63
64 void QuicUnackedPacketMap::OnRetransmittedPacket( 64 void QuicUnackedPacketMap::OnRetransmittedPacket(
65 QuicPacketSequenceNumber old_sequence_number, 65 QuicPacketSequenceNumber old_sequence_number,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 bool QuicUnackedPacketMap::IsPacketUseless( 201 bool QuicUnackedPacketMap::IsPacketUseless(
202 QuicPacketSequenceNumber sequence_number, 202 QuicPacketSequenceNumber sequence_number,
203 const TransmissionInfo& info) const { 203 const TransmissionInfo& info) const {
204 return sequence_number <= largest_observed_ && 204 return sequence_number <= largest_observed_ &&
205 !info.in_flight && 205 !info.in_flight &&
206 info.retransmittable_frames == NULL && 206 info.retransmittable_frames == NULL &&
207 info.all_transmissions == NULL; 207 info.all_transmissions == NULL;
208 } 208 }
209 209
210 bool QuicUnackedPacketMap::IsPacketRemovable(
211 QuicPacketSequenceNumber sequence_number,
212 const TransmissionInfo& info) const {
213 return (sequence_number <= largest_observed_ ||
214 unacked_packets_.size() > kMaxTcpCongestionWindow) &&
215 !info.in_flight &&
216 info.retransmittable_frames == NULL &&
217 info.all_transmissions == NULL;
218 }
219
210 bool QuicUnackedPacketMap::IsUnacked( 220 bool QuicUnackedPacketMap::IsUnacked(
211 QuicPacketSequenceNumber sequence_number) const { 221 QuicPacketSequenceNumber sequence_number) const {
212 if (sequence_number < least_unacked_ || 222 if (sequence_number < least_unacked_ ||
213 sequence_number >= least_unacked_ + unacked_packets_.size()) { 223 sequence_number >= least_unacked_ + unacked_packets_.size()) {
214 return false; 224 return false;
215 } 225 }
216 return !IsPacketUseless(sequence_number, 226 return !IsPacketUseless(sequence_number,
217 unacked_packets_[sequence_number - least_unacked_]); 227 unacked_packets_[sequence_number - least_unacked_]);
218 } 228 }
219 229
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 TransmissionInfo* info = &unacked_packets_[sequence_number - least_unacked_]; 349 TransmissionInfo* info = &unacked_packets_[sequence_number - least_unacked_];
340 DCHECK(!info->in_flight); 350 DCHECK(!info->in_flight);
341 DCHECK_NE(0u, info->bytes_sent); 351 DCHECK_NE(0u, info->bytes_sent);
342 DCHECK(info->sent_time.IsInitialized()); 352 DCHECK(info->sent_time.IsInitialized());
343 353
344 bytes_in_flight_ += info->bytes_sent; 354 bytes_in_flight_ += info->bytes_sent;
345 info->in_flight = true; 355 info->in_flight = true;
346 } 356 }
347 357
348 } // namespace net 358 } // 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