OLD | NEW |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 TransmissionInfo* transmission_info = | 67 TransmissionInfo* transmission_info = |
68 FindOrNull(unacked_packets_, old_sequence_number); | 68 FindOrNull(unacked_packets_, old_sequence_number); |
69 RetransmittableFrames* frames = transmission_info->retransmittable_frames; | 69 RetransmittableFrames* frames = transmission_info->retransmittable_frames; |
70 LOG_IF(DFATAL, frames == NULL) << "Attempt to retransmit packet with no " | 70 LOG_IF(DFATAL, frames == NULL) << "Attempt to retransmit packet with no " |
71 << "retransmittable frames: " | 71 << "retransmittable frames: " |
72 << old_sequence_number; | 72 << old_sequence_number; |
73 | 73 |
74 // We keep the old packet in the unacked packet list until it, or one of | 74 // We keep the old packet in the unacked packet list until it, or one of |
75 // the retransmissions of it are acked. | 75 // the retransmissions of it are acked. |
76 transmission_info->retransmittable_frames = NULL; | 76 transmission_info->retransmittable_frames = NULL; |
| 77 // Only keep one transmission older than largest observed, because only the |
| 78 // most recent is expected to possibly be a spurious retransmission. |
| 79 if (transmission_info->all_transmissions->size() > 1 && |
| 80 *(++transmission_info->all_transmissions->begin()) < largest_observed_) { |
| 81 QuicPacketSequenceNumber old_transmission = |
| 82 *transmission_info->all_transmissions->begin(); |
| 83 transmission_info->all_transmissions->erase(old_transmission); |
| 84 unacked_packets_.erase(old_transmission); |
| 85 } |
77 unacked_packets_[new_sequence_number] = | 86 unacked_packets_[new_sequence_number] = |
78 TransmissionInfo(frames, | 87 TransmissionInfo(frames, |
79 new_sequence_number, | 88 new_sequence_number, |
80 transmission_info->sequence_number_length, | 89 transmission_info->sequence_number_length, |
81 transmission_type, | 90 transmission_type, |
82 transmission_info->all_transmissions); | 91 transmission_info->all_transmissions); |
83 } | 92 } |
84 | 93 |
85 void QuicUnackedPacketMap::ClearPreviousRetransmissions(size_t num_to_clear) { | 94 void QuicUnackedPacketMap::ClearPreviousRetransmissions(size_t num_to_clear) { |
86 UnackedPacketMap::iterator it = unacked_packets_.begin(); | 95 UnackedPacketMap::iterator it = unacked_packets_.begin(); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 340 } |
332 DCHECK(!it->second.in_flight); | 341 DCHECK(!it->second.in_flight); |
333 DCHECK_NE(0u, it->second.bytes_sent); | 342 DCHECK_NE(0u, it->second.bytes_sent); |
334 DCHECK(it->second.sent_time.IsInitialized()); | 343 DCHECK(it->second.sent_time.IsInitialized()); |
335 | 344 |
336 bytes_in_flight_ += it->second.bytes_sent; | 345 bytes_in_flight_ += it->second.bytes_sent; |
337 it->second.in_flight = true; | 346 it->second.in_flight = true; |
338 } | 347 } |
339 | 348 |
340 } // namespace net | 349 } // namespace net |
OLD | NEW |