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

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

Issue 288313003: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: implemented rch's comments Created 6 years, 7 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
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (transmission_info->retransmittable_frames->HasCryptoHandshake() 159 if (transmission_info->retransmittable_frames->HasCryptoHandshake()
160 == IS_HANDSHAKE) { 160 == IS_HANDSHAKE) {
161 --pending_crypto_packet_count_; 161 --pending_crypto_packet_count_;
162 } 162 }
163 delete transmission_info->retransmittable_frames; 163 delete transmission_info->retransmittable_frames;
164 transmission_info->retransmittable_frames = NULL; 164 transmission_info->retransmittable_frames = NULL;
165 } 165 }
166 } 166 }
167 167
168 // static 168 // static
169 bool QuicUnackedPacketMap::IsSentAndNotPending( 169 bool QuicUnackedPacketMap::IsForRttOnly(
170 const TransmissionInfo& transmission_info) { 170 const TransmissionInfo& transmission_info) {
171 return !transmission_info.pending && 171 return !transmission_info.pending &&
172 transmission_info.sent_time != QuicTime::Zero() && 172 transmission_info.retransmittable_frames == NULL &&
173 transmission_info.bytes_sent == 0; 173 transmission_info.all_transmissions->size() == 1;
174 } 174 }
175 175
176 bool QuicUnackedPacketMap::IsUnacked( 176 bool QuicUnackedPacketMap::IsUnacked(
177 QuicPacketSequenceNumber sequence_number) const { 177 QuicPacketSequenceNumber sequence_number) const {
178 return ContainsKey(unacked_packets_, sequence_number); 178 return ContainsKey(unacked_packets_, sequence_number);
179 } 179 }
180 180
181 void QuicUnackedPacketMap::SetNotPending( 181 void QuicUnackedPacketMap::SetNotPending(
182 QuicPacketSequenceNumber sequence_number) { 182 QuicPacketSequenceNumber sequence_number) {
183 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number); 183 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number);
184 if (it == unacked_packets_.end()) { 184 if (it == unacked_packets_.end()) {
185 LOG(DFATAL) << "SetNotPending called for packet that is not unacked: " 185 LOG(DFATAL) << "SetNotPending called for packet that is not unacked: "
186 << sequence_number; 186 << sequence_number;
187 return; 187 return;
188 } 188 }
189 if (it->second.pending) { 189 if (it->second.pending) {
190 LOG_IF(DFATAL, bytes_in_flight_ < it->second.bytes_sent); 190 LOG_IF(DFATAL, bytes_in_flight_ < it->second.bytes_sent);
191 bytes_in_flight_ -= it->second.bytes_sent; 191 bytes_in_flight_ -= it->second.bytes_sent;
192 it->second.pending = false; 192 it->second.pending = false;
193 } 193 }
194 } 194 }
195 195
196 bool QuicUnackedPacketMap::HasUnackedPackets() const { 196 bool QuicUnackedPacketMap::HasUnackedPackets() const {
197 return !unacked_packets_.empty(); 197 return !unacked_packets_.empty();
198 } 198 }
199 199
200 bool QuicUnackedPacketMap::HasPendingPackets() const { 200 bool QuicUnackedPacketMap::HasPendingPackets() const {
201 for (UnackedPacketMap::const_reverse_iterator it = 201 return bytes_in_flight_ > 0;
202 unacked_packets_.rbegin(); it != unacked_packets_.rend(); ++it) {
203 if (it->second.pending) {
204 return true;
205 }
206 }
207 return false;
208 } 202 }
209 203
210 const TransmissionInfo& QuicUnackedPacketMap::GetTransmissionInfo( 204 const TransmissionInfo& QuicUnackedPacketMap::GetTransmissionInfo(
211 QuicPacketSequenceNumber sequence_number) const { 205 QuicPacketSequenceNumber sequence_number) const {
212 return unacked_packets_.find(sequence_number)->second; 206 return unacked_packets_.find(sequence_number)->second;
213 } 207 }
214 208
215 QuicTime QuicUnackedPacketMap::GetLastPacketSentTime() const { 209 QuicTime QuicUnackedPacketMap::GetLastPacketSentTime() const {
216 UnackedPacketMap::const_reverse_iterator it = unacked_packets_.rbegin(); 210 UnackedPacketMap::const_reverse_iterator it = unacked_packets_.rbegin();
217 while (it != unacked_packets_.rend()) { 211 while (it != unacked_packets_.rend()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 bool QuicUnackedPacketMap::HasUnackedRetransmittableFrames() const { 258 bool QuicUnackedPacketMap::HasUnackedRetransmittableFrames() const {
265 for (UnackedPacketMap::const_reverse_iterator it = 259 for (UnackedPacketMap::const_reverse_iterator it =
266 unacked_packets_.rbegin(); it != unacked_packets_.rend(); ++it) { 260 unacked_packets_.rbegin(); it != unacked_packets_.rend(); ++it) {
267 if (it->second.pending && it->second.retransmittable_frames) { 261 if (it->second.pending && it->second.retransmittable_frames) {
268 return true; 262 return true;
269 } 263 }
270 } 264 }
271 return false; 265 return false;
272 } 266 }
273 267
274 size_t QuicUnackedPacketMap::GetNumRetransmittablePackets() const {
275 size_t num_unacked_packets = 0;
276 for (UnackedPacketMap::const_iterator it = unacked_packets_.begin();
277 it != unacked_packets_.end(); ++it) {
278 if (it->second.retransmittable_frames != NULL) {
279 ++num_unacked_packets;
280 }
281 }
282 return num_unacked_packets;
283 }
284
285 QuicPacketSequenceNumber 268 QuicPacketSequenceNumber
286 QuicUnackedPacketMap::GetLeastUnackedSentPacket() const { 269 QuicUnackedPacketMap::GetLeastUnackedSentPacket() const {
287 if (unacked_packets_.empty()) { 270 if (unacked_packets_.empty()) {
288 // If there are no unacked packets, return 0. 271 // If there are no unacked packets, return 0.
289 return 0; 272 return 0;
290 } 273 }
291 274
292 return unacked_packets_.begin()->first; 275 return unacked_packets_.begin()->first;
293 } 276 }
294 277
(...skipping 13 matching lines...) Expand all
308 largest_sent_packet_ = max(sequence_number, largest_sent_packet_); 291 largest_sent_packet_ = max(sequence_number, largest_sent_packet_);
309 it->second.sent_time = sent_time; 292 it->second.sent_time = sent_time;
310 if (set_pending) { 293 if (set_pending) {
311 bytes_in_flight_ += bytes_sent; 294 bytes_in_flight_ += bytes_sent;
312 it->second.bytes_sent = bytes_sent; 295 it->second.bytes_sent = bytes_sent;
313 it->second.pending = true; 296 it->second.pending = true;
314 } 297 }
315 } 298 }
316 299
317 } // namespace net 300 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698