| 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" | |
| 8 | |
| 9 namespace net { | 7 namespace net { |
| 10 namespace { | 8 namespace { |
| 11 | 9 |
| 12 // The estimated system alarm granularity. | 10 // The estimated system alarm granularity. |
| 13 static const QuicTime::Delta kAlarmGranularity = | 11 static const QuicTime::Delta kAlarmGranularity = |
| 14 QuicTime::Delta::FromMilliseconds(1); | 12 QuicTime::Delta::FromMilliseconds(1); |
| 15 | 13 |
| 16 // Configured maximum size of the burst coming out of quiescence. The burst | 14 // Configured maximum size of the burst coming out of quiescence. The burst |
| 17 // is never larger than the current CWND in packets. | 15 // is never larger than the current CWND in packets. |
| 18 static const uint32_t kInitialUnpacedBurst = 10; | 16 static const uint32_t kInitialUnpacedBurst = 10; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 119 } |
| 122 | 120 |
| 123 if (!time_until_send.IsZero()) { | 121 if (!time_until_send.IsZero()) { |
| 124 DCHECK(time_until_send.IsInfinite()); | 122 DCHECK(time_until_send.IsInfinite()); |
| 125 // The underlying sender prevents sending. | 123 // The underlying sender prevents sending. |
| 126 return time_until_send; | 124 return time_until_send; |
| 127 } | 125 } |
| 128 | 126 |
| 129 // If the next send time is within the alarm granularity, send immediately. | 127 // If the next send time is within the alarm granularity, send immediately. |
| 130 if (ideal_next_packet_send_time_ > now + kAlarmGranularity) { | 128 if (ideal_next_packet_send_time_ > now + kAlarmGranularity) { |
| 131 QUIC_DVLOG(1) << "Delaying packet: " | 129 DVLOG(1) << "Delaying packet: " |
| 132 << (ideal_next_packet_send_time_ - now).ToMicroseconds(); | 130 << (ideal_next_packet_send_time_ - now).ToMicroseconds(); |
| 133 was_last_send_delayed_ = true; | 131 was_last_send_delayed_ = true; |
| 134 return ideal_next_packet_send_time_ - now; | 132 return ideal_next_packet_send_time_ - now; |
| 135 } | 133 } |
| 136 | 134 |
| 137 QUIC_DVLOG(1) << "Sending packet now"; | 135 DVLOG(1) << "Sending packet now"; |
| 138 return QuicTime::Delta::Zero(); | 136 return QuicTime::Delta::Zero(); |
| 139 } | 137 } |
| 140 | 138 |
| 141 QuicBandwidth PacingSender::PacingRate(QuicByteCount bytes_in_flight) const { | 139 QuicBandwidth PacingSender::PacingRate(QuicByteCount bytes_in_flight) const { |
| 142 DCHECK(sender_ != nullptr); | 140 DCHECK(sender_ != nullptr); |
| 143 if (!max_pacing_rate_.IsZero()) { | 141 if (!max_pacing_rate_.IsZero()) { |
| 144 return QuicBandwidth::FromBitsPerSecond( | 142 return QuicBandwidth::FromBitsPerSecond( |
| 145 std::min(max_pacing_rate_.ToBitsPerSecond(), | 143 std::min(max_pacing_rate_.ToBitsPerSecond(), |
| 146 sender_->PacingRate(bytes_in_flight).ToBitsPerSecond())); | 144 sender_->PacingRate(bytes_in_flight).ToBitsPerSecond())); |
| 147 } | 145 } |
| 148 return sender_->PacingRate(bytes_in_flight); | 146 return sender_->PacingRate(bytes_in_flight); |
| 149 } | 147 } |
| 150 | 148 |
| 151 } // namespace net | 149 } // namespace net |
| OLD | NEW |