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

Side by Side Diff: net/quic/congestion_control/send_algorithm_simulator.cc

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/congestion_control/send_algorithm_simulator.h" 5 #include "net/quic/congestion_control/send_algorithm_simulator.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 << send_event.time_delta.ToMicroseconds() << "us"; 106 << send_event.time_delta.ToMicroseconds() << "us";
107 clock_->AdvanceTime(send_event.time_delta); 107 clock_->AdvanceTime(send_event.time_delta);
108 SendDataNow(send_event.transfer); 108 SendDataNow(send_event.transfer);
109 bytes_sent += kPacketSize; 109 bytes_sent += kPacketSize;
110 } 110 }
111 } 111 }
112 } 112 }
113 113
114 SendAlgorithmSimulator::PacketEvent SendAlgorithmSimulator::NextSendEvent() { 114 SendAlgorithmSimulator::PacketEvent SendAlgorithmSimulator::NextSendEvent() {
115 QuicTime::Delta next_send_time = QuicTime::Delta::Infinite(); 115 QuicTime::Delta next_send_time = QuicTime::Delta::Infinite();
116 Transfer* transfer = NULL; 116 Transfer* transfer = nullptr;
117 for (vector<Transfer>::iterator it = pending_transfers_.begin(); 117 for (vector<Transfer>::iterator it = pending_transfers_.begin();
118 it != pending_transfers_.end(); ++it) { 118 it != pending_transfers_.end(); ++it) {
119 // If we've already sent enough bytes, wait for them to be acked. 119 // If we've already sent enough bytes, wait for them to be acked.
120 if (it->bytes_acked + it->bytes_in_flight >= it->num_bytes) { 120 if (it->bytes_acked + it->bytes_in_flight >= it->num_bytes) {
121 continue; 121 continue;
122 } 122 }
123 // If the flow hasn't started, use the start time. 123 // If the flow hasn't started, use the start time.
124 QuicTime::Delta transfer_send_time = it->start_time.Subtract(clock_->Now()); 124 QuicTime::Delta transfer_send_time = it->start_time.Subtract(clock_->Now());
125 if (clock_->Now() >= it->start_time) { 125 if (clock_->Now() >= it->start_time) {
126 transfer_send_time = 126 transfer_send_time =
127 it->sender->send_algorithm->TimeUntilSend( 127 it->sender->send_algorithm->TimeUntilSend(
128 clock_->Now(), it->bytes_in_flight, HAS_RETRANSMITTABLE_DATA); 128 clock_->Now(), it->bytes_in_flight, HAS_RETRANSMITTABLE_DATA);
129 } 129 }
130 if (transfer_send_time < next_send_time) { 130 if (transfer_send_time < next_send_time) {
131 next_send_time = transfer_send_time; 131 next_send_time = transfer_send_time;
132 transfer = &(*it); 132 transfer = &(*it);
133 } 133 }
134 } 134 }
135 DVLOG(1) << "NextSendTime returning delta(ms):" 135 DVLOG(1) << "NextSendTime returning delta(ms):"
136 << next_send_time.ToMilliseconds(); 136 << next_send_time.ToMilliseconds();
137 return PacketEvent(next_send_time, transfer); 137 return PacketEvent(next_send_time, transfer);
138 } 138 }
139 139
140 // NextAck takes into account packet loss in both forward and reverse 140 // NextAck takes into account packet loss in both forward and reverse
141 // direction, as well as correlated losses. And it assumes the receiver acks 141 // direction, as well as correlated losses. And it assumes the receiver acks
142 // every other packet when there is no loss. 142 // every other packet when there is no loss.
143 SendAlgorithmSimulator::PacketEvent SendAlgorithmSimulator::NextAckEvent() { 143 SendAlgorithmSimulator::PacketEvent SendAlgorithmSimulator::NextAckEvent() {
144 if (sent_packets_.empty()) { 144 if (sent_packets_.empty()) {
145 DVLOG(1) << "No outstanding packets to ack for any transfer."; 145 DVLOG(1) << "No outstanding packets to ack for any transfer.";
146 return PacketEvent(QuicTime::Delta::Infinite(), NULL); 146 return PacketEvent(QuicTime::Delta::Infinite(), nullptr);
147 } 147 }
148 148
149 // For each connection, find the next acked packet. 149 // For each connection, find the next acked packet.
150 QuicTime::Delta ack_time = QuicTime::Delta::Infinite(); 150 QuicTime::Delta ack_time = QuicTime::Delta::Infinite();
151 Transfer* transfer = NULL; 151 Transfer* transfer = nullptr;
152 for (vector<Transfer>::iterator it = pending_transfers_.begin(); 152 for (vector<Transfer>::iterator it = pending_transfers_.begin();
153 it != pending_transfers_.end(); ++it) { 153 it != pending_transfers_.end(); ++it) {
154 QuicTime::Delta transfer_ack_time = FindNextAcked(&(*it)); 154 QuicTime::Delta transfer_ack_time = FindNextAcked(&(*it));
155 if (transfer_ack_time < ack_time) { 155 if (transfer_ack_time < ack_time) {
156 ack_time = transfer_ack_time; 156 ack_time = transfer_ack_time;
157 transfer = &(*it); 157 transfer = &(*it);
158 } 158 }
159 } 159 }
160 160
161 return PacketEvent(ack_time, transfer); 161 return PacketEvent(ack_time, transfer);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } 364 }
365 transfer->bytes_in_flight += kPacketSize; 365 transfer->bytes_in_flight += kPacketSize;
366 } 366 }
367 367
368 // Advance the time by |delta| without sending anything. 368 // Advance the time by |delta| without sending anything.
369 void SendAlgorithmSimulator::AdvanceTime(QuicTime::Delta delta) { 369 void SendAlgorithmSimulator::AdvanceTime(QuicTime::Delta delta) {
370 clock_->AdvanceTime(delta); 370 clock_->AdvanceTime(delta);
371 } 371 }
372 372
373 } // namespace net 373 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/send_algorithm_simulator.h ('k') | net/quic/congestion_control/tcp_loss_algorithm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698