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

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

Issue 282323003: Minor cleanup of QuicUnackedPacketMap to simplify the implementation of (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
« no previous file with comments | « net/quic/quic_unacked_packet_map.h ('k') | net/quic/test_tools/quic_sent_packet_manager_peer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698