| 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/congestion_control/pacing_sender.h" | 5 #include "net/quic/congestion_control/pacing_sender.h" |
| 6 | 6 |
| 7 namespace net { | 7 namespace net { |
| 8 | 8 |
| 9 PacingSender::PacingSender(SendAlgorithmInterface* sender, | 9 PacingSender::PacingSender(SendAlgorithmInterface* sender, |
| 10 QuicTime::Delta alarm_granularity, | 10 QuicTime::Delta alarm_granularity, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 feedback, feedback_receive_time); | 34 feedback, feedback_receive_time); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void PacingSender::OnCongestionEvent(bool rtt_updated, | 37 void PacingSender::OnCongestionEvent(bool rtt_updated, |
| 38 QuicByteCount bytes_in_flight, | 38 QuicByteCount bytes_in_flight, |
| 39 const CongestionMap& acked_packets, | 39 const CongestionMap& acked_packets, |
| 40 const CongestionMap& lost_packets) { | 40 const CongestionMap& lost_packets) { |
| 41 if (rtt_updated) { | 41 if (rtt_updated) { |
| 42 has_valid_rtt_ = true; | 42 has_valid_rtt_ = true; |
| 43 } | 43 } |
| 44 if (bytes_in_flight == 0) { | |
| 45 // Add more burst tokens anytime the connection is entering quiescence. | |
| 46 burst_tokens_ = initial_packet_burst_; | |
| 47 } | |
| 48 sender_->OnCongestionEvent( | 44 sender_->OnCongestionEvent( |
| 49 rtt_updated, bytes_in_flight, acked_packets, lost_packets); | 45 rtt_updated, bytes_in_flight, acked_packets, lost_packets); |
| 50 } | 46 } |
| 51 | 47 |
| 52 bool PacingSender::OnPacketSent( | 48 bool PacingSender::OnPacketSent( |
| 53 QuicTime sent_time, | 49 QuicTime sent_time, |
| 54 QuicByteCount bytes_in_flight, | 50 QuicByteCount bytes_in_flight, |
| 55 QuicPacketSequenceNumber sequence_number, | 51 QuicPacketSequenceNumber sequence_number, |
| 56 QuicByteCount bytes, | 52 QuicByteCount bytes, |
| 57 HasRetransmittableData has_retransmittable_data) { | 53 HasRetransmittableData has_retransmittable_data) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 QuicTime::Delta PacingSender::TimeUntilSend( | 110 QuicTime::Delta PacingSender::TimeUntilSend( |
| 115 QuicTime now, | 111 QuicTime now, |
| 116 QuicByteCount bytes_in_flight, | 112 QuicByteCount bytes_in_flight, |
| 117 HasRetransmittableData has_retransmittable_data) const { | 113 HasRetransmittableData has_retransmittable_data) const { |
| 118 QuicTime::Delta time_until_send = | 114 QuicTime::Delta time_until_send = |
| 119 sender_->TimeUntilSend(now, bytes_in_flight, has_retransmittable_data); | 115 sender_->TimeUntilSend(now, bytes_in_flight, has_retransmittable_data); |
| 120 if (!has_valid_rtt_) { | 116 if (!has_valid_rtt_) { |
| 121 // Don't pace if we don't have an updated RTT estimate. | 117 // Don't pace if we don't have an updated RTT estimate. |
| 122 return time_until_send; | 118 return time_until_send; |
| 123 } | 119 } |
| 120 if (bytes_in_flight == 0) { |
| 121 // Add more burst tokens anytime the connection is entering quiescence. |
| 122 burst_tokens_ = initial_packet_burst_; |
| 123 } |
| 124 if (burst_tokens_ > 0) { | 124 if (burst_tokens_ > 0) { |
| 125 // Don't pace if we have burst tokens available. | 125 // Don't pace if we have burst tokens available. |
| 126 return time_until_send; | 126 return time_until_send; |
| 127 } | 127 } |
| 128 | 128 |
| 129 if (!time_until_send.IsZero()) { | 129 if (!time_until_send.IsZero()) { |
| 130 DCHECK(time_until_send.IsInfinite()); | 130 DCHECK(time_until_send.IsInfinite()); |
| 131 // The underlying sender prevents sending. | 131 // The underlying sender prevents sending. |
| 132 return time_until_send; | 132 return time_until_send; |
| 133 } | 133 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 160 | 160 |
| 161 QuicTime::Delta PacingSender::RetransmissionDelay() const { | 161 QuicTime::Delta PacingSender::RetransmissionDelay() const { |
| 162 return sender_->RetransmissionDelay(); | 162 return sender_->RetransmissionDelay(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 QuicByteCount PacingSender::GetCongestionWindow() const { | 165 QuicByteCount PacingSender::GetCongestionWindow() const { |
| 166 return sender_->GetCongestionWindow(); | 166 return sender_->GetCongestionWindow(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace net | 169 } // namespace net |
| OLD | NEW |