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

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

Issue 561513003: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 info->all_transmissions->pop_front(); 120 if (info->all_transmissions != NULL) {
121 LOG_IF(DFATAL, info->all_transmissions->empty()) 121 if (info->all_transmissions->size() < 2) {
122 << "Previous retransmissions must have a newer transmission."; 122 LOG(DFATAL) << "all_transmissions must be NULL or have multiple "
123 << "elements. size:" << info->all_transmissions->size();
124 delete info->all_transmissions;
125 } else {
126 info->all_transmissions->pop_front();
127 if (info->all_transmissions->size() == 1) {
128 // Set the newer transmission's 'all_transmissions' entry to NULL.
129 QuicPacketSequenceNumber new_transmission =
130 info->all_transmissions->front();
131 TransmissionInfo* new_info =
132 &unacked_packets_.at(new_transmission - least_unacked_);
133 delete new_info->all_transmissions;
134 new_info->all_transmissions = NULL;
135 }
136 }
137 }
123 unacked_packets_.pop_front(); 138 unacked_packets_.pop_front();
124 ++least_unacked_; 139 ++least_unacked_;
125 --num_to_clear;
126 } 140 }
127 } 141 }
128 142
129 bool QuicUnackedPacketMap::HasRetransmittableFrames( 143 bool QuicUnackedPacketMap::HasRetransmittableFrames(
130 QuicPacketSequenceNumber sequence_number) const { 144 QuicPacketSequenceNumber sequence_number) const {
131 DCHECK_GE(sequence_number, least_unacked_); 145 DCHECK_GE(sequence_number, least_unacked_);
132 DCHECK_LT(sequence_number, least_unacked_ + unacked_packets_.size()); 146 DCHECK_LT(sequence_number, least_unacked_ + unacked_packets_.size());
133 return unacked_packets_[ 147 return unacked_packets_[
134 sequence_number - least_unacked_].retransmittable_frames != NULL; 148 sequence_number - least_unacked_].retransmittable_frames != NULL;
135 } 149 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 199
186 bool QuicUnackedPacketMap::IsPacketUseless( 200 bool QuicUnackedPacketMap::IsPacketUseless(
187 QuicPacketSequenceNumber sequence_number, 201 QuicPacketSequenceNumber sequence_number,
188 const TransmissionInfo& info) const { 202 const TransmissionInfo& info) const {
189 return sequence_number <= largest_observed_ && 203 return sequence_number <= largest_observed_ &&
190 !info.in_flight && 204 !info.in_flight &&
191 info.retransmittable_frames == NULL && 205 info.retransmittable_frames == NULL &&
192 info.all_transmissions == NULL; 206 info.all_transmissions == NULL;
193 } 207 }
194 208
209 bool QuicUnackedPacketMap::IsPacketRemovable(
210 QuicPacketSequenceNumber sequence_number,
211 const TransmissionInfo& info) const {
212 return (sequence_number <= largest_observed_ ||
213 unacked_packets_.size() > kMaxTcpCongestionWindow) &&
214 !info.in_flight &&
215 info.retransmittable_frames == NULL &&
216 info.all_transmissions == NULL;
217 }
218
195 bool QuicUnackedPacketMap::IsUnacked( 219 bool QuicUnackedPacketMap::IsUnacked(
196 QuicPacketSequenceNumber sequence_number) const { 220 QuicPacketSequenceNumber sequence_number) const {
197 if (sequence_number < least_unacked_ || 221 if (sequence_number < least_unacked_ ||
198 sequence_number >= least_unacked_ + unacked_packets_.size()) { 222 sequence_number >= least_unacked_ + unacked_packets_.size()) {
199 return false; 223 return false;
200 } 224 }
201 return !IsPacketUseless(sequence_number, 225 return !IsPacketUseless(sequence_number,
202 unacked_packets_[sequence_number - least_unacked_]); 226 unacked_packets_[sequence_number - least_unacked_]);
203 } 227 }
204 228
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 TransmissionInfo* info = &unacked_packets_[sequence_number - least_unacked_]; 348 TransmissionInfo* info = &unacked_packets_[sequence_number - least_unacked_];
325 DCHECK(!info->in_flight); 349 DCHECK(!info->in_flight);
326 DCHECK_NE(0u, info->bytes_sent); 350 DCHECK_NE(0u, info->bytes_sent);
327 DCHECK(info->sent_time.IsInitialized()); 351 DCHECK(info->sent_time.IsInitialized());
328 352
329 bytes_in_flight_ += info->bytes_sent; 353 bytes_in_flight_ += info->bytes_sent;
330 info->in_flight = true; 354 info->in_flight = true;
331 } 355 }
332 356
333 } // namespace net 357 } // 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