| Index: net/quic/core/congestion_control/pacing_sender.cc
|
| diff --git a/net/quic/core/congestion_control/pacing_sender.cc b/net/quic/core/congestion_control/pacing_sender.cc
|
| index 555a9cee6b4c3742f73ae70b4c863ac606df01fd..cc2c40b8cb31120bd09df9ebe2b5ef3574b152ce 100644
|
| --- a/net/quic/core/congestion_control/pacing_sender.cc
|
| +++ b/net/quic/core/congestion_control/pacing_sender.cc
|
| @@ -11,45 +11,39 @@
|
| using std::min;
|
|
|
| namespace net {
|
| +namespace {
|
|
|
| -PacingSender::PacingSender(SendAlgorithmInterface* sender,
|
| - QuicTime::Delta alarm_granularity,
|
| - uint32_t initial_packet_burst)
|
| - : sender_(sender),
|
| - alarm_granularity_(alarm_granularity),
|
| - initial_packet_burst_(initial_packet_burst),
|
| +// The estimated system alarm granularity.
|
| +static const QuicTime::Delta kAlarmGranularity =
|
| + QuicTime::Delta::FromMilliseconds(1);
|
| +
|
| +// Configured maximum size of the burst coming out of quiescence. The burst
|
| +// is never larger than the current CWND in packets.
|
| +static const uint32_t kInitialUnpacedBurst = 10;
|
| +
|
| +} // namespace
|
| +
|
| +PacingSender::PacingSender()
|
| + : sender_(nullptr),
|
| max_pacing_rate_(QuicBandwidth::Zero()),
|
| - burst_tokens_(initial_packet_burst),
|
| + burst_tokens_(kInitialUnpacedBurst),
|
| last_delayed_packet_sent_time_(QuicTime::Zero()),
|
| ideal_next_packet_send_time_(QuicTime::Zero()),
|
| was_last_send_delayed_(false) {}
|
|
|
| PacingSender::~PacingSender() {}
|
|
|
| -void PacingSender::SetFromConfig(const QuicConfig& config,
|
| - Perspective perspective) {
|
| - sender_->SetFromConfig(config, perspective);
|
| -}
|
| -
|
| -void PacingSender::ResumeConnectionState(
|
| - const CachedNetworkParameters& cached_network_params,
|
| - bool max_bandwidth_resumption) {
|
| - sender_->ResumeConnectionState(cached_network_params,
|
| - max_bandwidth_resumption);
|
| -}
|
| -
|
| -void PacingSender::SetNumEmulatedConnections(int num_connections) {
|
| - sender_->SetNumEmulatedConnections(num_connections);
|
| -}
|
| -
|
| -void PacingSender::SetMaxPacingRate(QuicBandwidth max_pacing_rate) {
|
| - max_pacing_rate_ = max_pacing_rate;
|
| +void PacingSender::set_sender(SendAlgorithmInterface* sender) {
|
| + DCHECK(sender != nullptr);
|
| + sender_ = sender;
|
| }
|
|
|
| -void PacingSender::OnCongestionEvent(bool rtt_updated,
|
| - QuicByteCount bytes_in_flight,
|
| - const CongestionVector& acked_packets,
|
| - const CongestionVector& lost_packets) {
|
| +void PacingSender::OnCongestionEvent(
|
| + bool rtt_updated,
|
| + QuicByteCount bytes_in_flight,
|
| + const SendAlgorithmInterface::CongestionVector& acked_packets,
|
| + const SendAlgorithmInterface::CongestionVector& lost_packets) {
|
| + DCHECK(sender_ != nullptr);
|
| if (!lost_packets.empty()) {
|
| // Clear any burst tokens when entering recovery.
|
| burst_tokens_ = 0;
|
| @@ -64,6 +58,7 @@ bool PacingSender::OnPacketSent(
|
| QuicPacketNumber packet_number,
|
| QuicByteCount bytes,
|
| HasRetransmittableData has_retransmittable_data) {
|
| + DCHECK(sender_ != nullptr);
|
| const bool in_flight =
|
| sender_->OnPacketSent(sent_time, bytes_in_flight, packet_number, bytes,
|
| has_retransmittable_data);
|
| @@ -76,7 +71,7 @@ bool PacingSender::OnPacketSent(
|
| // limit it to the equivalent of a single bulk write, not exceeding the
|
| // current CWND in packets.
|
| burst_tokens_ = min(
|
| - initial_packet_burst_,
|
| + kInitialUnpacedBurst,
|
| static_cast<uint32_t>(sender_->GetCongestionWindow() / kDefaultTCPMSS));
|
| }
|
| if (burst_tokens_ > 0) {
|
| @@ -117,17 +112,10 @@ bool PacingSender::OnPacketSent(
|
| return in_flight;
|
| }
|
|
|
| -void PacingSender::OnRetransmissionTimeout(bool packets_retransmitted) {
|
| - sender_->OnRetransmissionTimeout(packets_retransmitted);
|
| -}
|
| -
|
| -void PacingSender::OnConnectionMigration() {
|
| - sender_->OnConnectionMigration();
|
| -}
|
| -
|
| QuicTime::Delta PacingSender::TimeUntilSend(
|
| QuicTime now,
|
| QuicByteCount bytes_in_flight) const {
|
| + DCHECK(sender_ != nullptr);
|
| QuicTime::Delta time_until_send =
|
| sender_->TimeUntilSend(now, bytes_in_flight);
|
| if (burst_tokens_ > 0 || bytes_in_flight == 0) {
|
| @@ -142,7 +130,7 @@ QuicTime::Delta PacingSender::TimeUntilSend(
|
| }
|
|
|
| // If the next send time is within the alarm granularity, send immediately.
|
| - if (ideal_next_packet_send_time_ > now + alarm_granularity_) {
|
| + if (ideal_next_packet_send_time_ > now + kAlarmGranularity) {
|
| DVLOG(1) << "Delaying packet: "
|
| << (ideal_next_packet_send_time_ - now).ToMicroseconds();
|
| was_last_send_delayed_ = true;
|
| @@ -154,6 +142,7 @@ QuicTime::Delta PacingSender::TimeUntilSend(
|
| }
|
|
|
| QuicBandwidth PacingSender::PacingRate(QuicByteCount bytes_in_flight) const {
|
| + DCHECK(sender_ != nullptr);
|
| if (!max_pacing_rate_.IsZero()) {
|
| return QuicBandwidth::FromBitsPerSecond(
|
| min(max_pacing_rate_.ToBitsPerSecond(),
|
| @@ -162,38 +151,4 @@ QuicBandwidth PacingSender::PacingRate(QuicByteCount bytes_in_flight) const {
|
| return sender_->PacingRate(bytes_in_flight);
|
| }
|
|
|
| -QuicBandwidth PacingSender::BandwidthEstimate() const {
|
| - return sender_->BandwidthEstimate();
|
| -}
|
| -
|
| -QuicTime::Delta PacingSender::RetransmissionDelay() const {
|
| - return sender_->RetransmissionDelay();
|
| -}
|
| -
|
| -QuicByteCount PacingSender::GetCongestionWindow() const {
|
| - return sender_->GetCongestionWindow();
|
| -}
|
| -
|
| -bool PacingSender::InSlowStart() const {
|
| - return sender_->InSlowStart();
|
| -}
|
| -
|
| -bool PacingSender::InRecovery() const {
|
| - return sender_->InRecovery();
|
| -}
|
| -
|
| -QuicByteCount PacingSender::GetSlowStartThreshold() const {
|
| - return sender_->GetSlowStartThreshold();
|
| -}
|
| -
|
| -CongestionControlType PacingSender::GetCongestionControlType() const {
|
| - return sender_->GetCongestionControlType();
|
| -}
|
| -
|
| -std::string PacingSender::GetDebugState() const {
|
| - return sender_->GetDebugState();
|
| -}
|
| -
|
| -void PacingSender::OnApplicationLimited(QuicByteCount bytes_in_flight) {}
|
| -
|
| } // namespace net
|
|
|