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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 transmission_info->all_transmissions->push_back(old_sequence_number); | 100 transmission_info->all_transmissions->push_back(old_sequence_number); |
101 } | 101 } |
102 transmission_info->all_transmissions->push_back(new_sequence_number); | 102 transmission_info->all_transmissions->push_back(new_sequence_number); |
103 unacked_packets_.push_back( | 103 unacked_packets_.push_back( |
104 TransmissionInfo(frames, | 104 TransmissionInfo(frames, |
105 transmission_info->sequence_number_length, | 105 transmission_info->sequence_number_length, |
106 transmission_type, | 106 transmission_type, |
107 transmission_info->all_transmissions)); | 107 transmission_info->all_transmissions)); |
108 } | 108 } |
109 | 109 |
110 void QuicUnackedPacketMap::ClearPreviousRetransmissions(size_t num_to_clear) { | 110 void QuicUnackedPacketMap::ClearAllPreviousRetransmissions() { |
111 while (!unacked_packets_.empty() && num_to_clear > 0) { | 111 while (!unacked_packets_.empty() && least_unacked_ < largest_observed_) { |
112 // If this packet is in flight, or has retransmittable data, then there is | 112 // If this packet is in flight, or has retransmittable data, then there is |
113 // no point in clearing out any further packets, because they would not | 113 // no point in clearing out any further packets, because they would not |
114 // affect the high water mark. | 114 // affect the high water mark. |
115 TransmissionInfo* info = &unacked_packets_.front(); | 115 TransmissionInfo* info = &unacked_packets_.front(); |
116 if (info->in_flight || info->retransmittable_frames != NULL) { | 116 if (info->in_flight || info->retransmittable_frames != NULL) { |
117 break; | 117 break; |
118 } | 118 } |
119 | 119 |
120 if (info->all_transmissions != NULL) { | 120 if (info->all_transmissions != NULL) { |
121 if (info->all_transmissions->size() < 2) { | 121 if (info->all_transmissions->size() < 2) { |
122 LOG(DFATAL) << "all_transmissions must be NULL or have multiple " | 122 LOG(DFATAL) << "all_transmissions must be NULL or have multiple " |
123 << "elements. size:" << info->all_transmissions->size(); | 123 << "elements. size:" << info->all_transmissions->size(); |
124 delete info->all_transmissions; | 124 delete info->all_transmissions; |
125 } else { | 125 } else { |
126 info->all_transmissions->pop_front(); | 126 info->all_transmissions->pop_front(); |
127 if (info->all_transmissions->size() == 1) { | 127 if (info->all_transmissions->size() == 1) { |
128 // Set the newer transmission's 'all_transmissions' entry to NULL. | 128 // Set the newer transmission's 'all_transmissions' entry to NULL. |
129 QuicPacketSequenceNumber new_transmission = | 129 QuicPacketSequenceNumber new_transmission = |
130 info->all_transmissions->front(); | 130 info->all_transmissions->front(); |
131 TransmissionInfo* new_info = | 131 TransmissionInfo* new_info = |
132 &unacked_packets_.at(new_transmission - least_unacked_); | 132 &unacked_packets_.at(new_transmission - least_unacked_); |
133 delete new_info->all_transmissions; | 133 delete new_info->all_transmissions; |
134 new_info->all_transmissions = NULL; | 134 new_info->all_transmissions = NULL; |
135 } | 135 } |
136 } | 136 } |
137 } | 137 } |
138 unacked_packets_.pop_front(); | 138 unacked_packets_.pop_front(); |
139 ++least_unacked_; | 139 ++least_unacked_; |
140 --num_to_clear; | |
141 } | 140 } |
142 } | 141 } |
143 | 142 |
144 bool QuicUnackedPacketMap::HasRetransmittableFrames( | 143 bool QuicUnackedPacketMap::HasRetransmittableFrames( |
145 QuicPacketSequenceNumber sequence_number) const { | 144 QuicPacketSequenceNumber sequence_number) const { |
146 DCHECK_GE(sequence_number, least_unacked_); | 145 DCHECK_GE(sequence_number, least_unacked_); |
147 DCHECK_LT(sequence_number, least_unacked_ + unacked_packets_.size()); | 146 DCHECK_LT(sequence_number, least_unacked_ + unacked_packets_.size()); |
148 return unacked_packets_[ | 147 return unacked_packets_[ |
149 sequence_number - least_unacked_].retransmittable_frames != NULL; | 148 sequence_number - least_unacked_].retransmittable_frames != NULL; |
150 } | 149 } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 TransmissionInfo* info = &unacked_packets_[sequence_number - least_unacked_]; | 348 TransmissionInfo* info = &unacked_packets_[sequence_number - least_unacked_]; |
350 DCHECK(!info->in_flight); | 349 DCHECK(!info->in_flight); |
351 DCHECK_NE(0u, info->bytes_sent); | 350 DCHECK_NE(0u, info->bytes_sent); |
352 DCHECK(info->sent_time.IsInitialized()); | 351 DCHECK(info->sent_time.IsInitialized()); |
353 | 352 |
354 bytes_in_flight_ += info->bytes_sent; | 353 bytes_in_flight_ += info->bytes_sent; |
355 info->in_flight = true; | 354 info->in_flight = true; |
356 } | 355 } |
357 | 356 |
358 } // namespace net | 357 } // namespace net |
OLD | NEW |