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

Unified Diff: net/quic/core/congestion_control/send_algorithm_simulator.cc

Issue 2236973002: Landing Recent QUIC changes until 4AM, Aug 7, 2016 UTC-4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: flip quic_sequencer_buffer_retire_block_in_time to true Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/core/congestion_control/send_algorithm_simulator.cc
diff --git a/net/quic/core/congestion_control/send_algorithm_simulator.cc b/net/quic/core/congestion_control/send_algorithm_simulator.cc
index b6cce651b4b026513e159810932acdc22c966377..bdb8b91e7e12610827a155b652a10067f5c39eda 100644
--- a/net/quic/core/congestion_control/send_algorithm_simulator.cc
+++ b/net/quic/core/congestion_control/send_algorithm_simulator.cc
@@ -92,18 +92,23 @@ void SendAlgorithmSimulator::AddTransfer(Sender* sender,
}
void SendAlgorithmSimulator::TransferBytes() {
- TransferBytes(std::numeric_limits<uint64_t>::max(),
- QuicTime::Delta::Infinite());
+ TransferBytesUntil([](QuicTime, QuicByteCount) { return false; });
}
void SendAlgorithmSimulator::TransferBytes(QuicByteCount max_bytes,
QuicTime::Delta max_time) {
- const QuicTime end_time = max_time.IsInfinite()
- ? QuicTime::Zero() + QuicTime::Delta::Infinite()
- : clock_->Now() + max_time;
+ const QuicTime start_time = clock_->Now();
+ TransferBytesUntil([=](QuicTime now, QuicByteCount bytes_sent) {
+ return bytes_sent >= max_bytes || now - start_time > max_time;
+ });
+}
+
+template <class TerminationPredicate>
+bool SendAlgorithmSimulator::TransferBytesUntil(
+ TerminationPredicate termination_predicate) {
QuicByteCount bytes_sent = 0;
- while (!pending_transfers_.empty() && clock_->Now() < end_time &&
- bytes_sent < max_bytes) {
+ while (!pending_transfers_.empty() &&
+ !termination_predicate(clock_->Now(), bytes_sent)) {
// Determine the times of next send and of the next ack arrival.
PacketEvent send_event = NextSendEvent();
PacketEvent ack_event = NextAckEvent();
@@ -133,6 +138,8 @@ void SendAlgorithmSimulator::TransferBytes(QuicByteCount max_bytes,
bytes_sent += kPacketSize;
}
}
+
+ return !pending_transfers_.empty();
}
SendAlgorithmSimulator::PacketEvent SendAlgorithmSimulator::NextSendEvent() {
« no previous file with comments | « net/quic/core/congestion_control/send_algorithm_simulator.h ('k') | net/quic/core/congestion_control/tcp_cubic_sender_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698