| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/core/congestion_control/pacing_sender.h" | 5 #include "net/quic/core/congestion_control/pacing_sender.h" |
| 6 | 6 |
| 7 #include "net/quic/platform/api/quic_logging.h" | 7 #include "net/quic/platform/api/quic_logging.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 namespace { | 10 namespace { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 was_last_send_delayed_ = false; | 102 was_last_send_delayed_ = false; |
| 103 last_delayed_packet_sent_time_ = QuicTime::Zero(); | 103 last_delayed_packet_sent_time_ = QuicTime::Zero(); |
| 104 } | 104 } |
| 105 } else { | 105 } else { |
| 106 ideal_next_packet_send_time_ = | 106 ideal_next_packet_send_time_ = |
| 107 std::max(ideal_next_packet_send_time_ + delay, sent_time + delay); | 107 std::max(ideal_next_packet_send_time_ + delay, sent_time + delay); |
| 108 } | 108 } |
| 109 return in_flight; | 109 return in_flight; |
| 110 } | 110 } |
| 111 | 111 |
| 112 QuicTime::Delta PacingSender::TimeUntilSend( | 112 QuicTime::Delta PacingSender::TimeUntilSend(QuicTime now, |
| 113 QuicTime now, | 113 QuicByteCount bytes_in_flight) { |
| 114 QuicByteCount bytes_in_flight) const { | |
| 115 DCHECK(sender_ != nullptr); | 114 DCHECK(sender_ != nullptr); |
| 116 QuicTime::Delta time_until_send = | 115 QuicTime::Delta time_until_send = |
| 117 sender_->TimeUntilSend(now, bytes_in_flight); | 116 sender_->TimeUntilSend(now, bytes_in_flight); |
| 118 if (burst_tokens_ > 0 || bytes_in_flight == 0) { | 117 if (burst_tokens_ > 0 || bytes_in_flight == 0) { |
| 119 // Don't pace if we have burst tokens available or leaving quiescence. | 118 // Don't pace if we have burst tokens available or leaving quiescence. |
| 120 return time_until_send; | 119 return time_until_send; |
| 121 } | 120 } |
| 122 | 121 |
| 123 if (!time_until_send.IsZero()) { | 122 if (!time_until_send.IsZero()) { |
| 124 DCHECK(time_until_send.IsInfinite()); | 123 DCHECK(time_until_send.IsInfinite()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 142 DCHECK(sender_ != nullptr); | 141 DCHECK(sender_ != nullptr); |
| 143 if (!max_pacing_rate_.IsZero()) { | 142 if (!max_pacing_rate_.IsZero()) { |
| 144 return QuicBandwidth::FromBitsPerSecond( | 143 return QuicBandwidth::FromBitsPerSecond( |
| 145 std::min(max_pacing_rate_.ToBitsPerSecond(), | 144 std::min(max_pacing_rate_.ToBitsPerSecond(), |
| 146 sender_->PacingRate(bytes_in_flight).ToBitsPerSecond())); | 145 sender_->PacingRate(bytes_in_flight).ToBitsPerSecond())); |
| 147 } | 146 } |
| 148 return sender_->PacingRate(bytes_in_flight); | 147 return sender_->PacingRate(bytes_in_flight); |
| 149 } | 148 } |
| 150 | 149 |
| 151 } // namespace net | 150 } // namespace net |
| OLD | NEW |