| OLD | NEW | 
|    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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   66   // Record initial stats from when the transfer begins. |   66   // Record initial stats from when the transfer begins. | 
|   67   pending_transfers_.back().sender->RecordStats(); |   67   pending_transfers_.back().sender->RecordStats(); | 
|   68 } |   68 } | 
|   69  |   69  | 
|   70 void SendAlgorithmSimulator::TransferBytes() { |   70 void SendAlgorithmSimulator::TransferBytes() { | 
|   71   TransferBytes(kuint64max, QuicTime::Delta::Infinite()); |   71   TransferBytes(kuint64max, QuicTime::Delta::Infinite()); | 
|   72 } |   72 } | 
|   73  |   73  | 
|   74 void SendAlgorithmSimulator::TransferBytes(QuicByteCount max_bytes, |   74 void SendAlgorithmSimulator::TransferBytes(QuicByteCount max_bytes, | 
|   75                                            QuicTime::Delta max_time) { |   75                                            QuicTime::Delta max_time) { | 
|   76   const QuicTime end_time = clock_->Now().Add(max_time); |   76   const QuicTime end_time = max_time.IsInfinite() ? | 
 |   77       QuicTime::Zero().Add(QuicTime::Delta::Infinite()) : | 
 |   78       clock_->Now().Add(max_time); | 
|   77   QuicByteCount bytes_sent = 0; |   79   QuicByteCount bytes_sent = 0; | 
|   78   while (!pending_transfers_.empty() && |   80   while (!pending_transfers_.empty() && | 
|   79          clock_->Now() < end_time && |   81          clock_->Now() < end_time && | 
|   80          bytes_sent < max_bytes) { |   82          bytes_sent < max_bytes) { | 
|   81     // Determine the times of next send and of the next ack arrival. |   83     // Determine the times of next send and of the next ack arrival. | 
|   82     PacketEvent send_event = NextSendEvent(); |   84     PacketEvent send_event = NextSendEvent(); | 
|   83     PacketEvent ack_event = NextAckEvent(); |   85     PacketEvent ack_event = NextAckEvent(); | 
|   84     // If both times are infinite, fire a TLP. |   86     // If both times are infinite, fire a TLP. | 
|   85     if (ack_event.time_delta.IsInfinite() && |   87     if (ack_event.time_delta.IsInfinite() && | 
|   86         send_event.time_delta.IsInfinite()) { |   88         send_event.time_delta.IsInfinite()) { | 
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  333   } |  335   } | 
|  334   transfer->bytes_in_flight += kPacketSize; |  336   transfer->bytes_in_flight += kPacketSize; | 
|  335 } |  337 } | 
|  336  |  338  | 
|  337 // Advance the time by |delta| without sending anything. |  339 // Advance the time by |delta| without sending anything. | 
|  338 void SendAlgorithmSimulator::AdvanceTime(QuicTime::Delta delta) { |  340 void SendAlgorithmSimulator::AdvanceTime(QuicTime::Delta delta) { | 
|  339   clock_->AdvanceTime(delta); |  341   clock_->AdvanceTime(delta); | 
|  340 } |  342 } | 
|  341  |  343  | 
|  342 }  // namespace net |  344 }  // namespace net | 
| OLD | NEW |