| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/quic_sent_packet_manager.h" | 5 #include "net/quic/quic_sent_packet_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); | 137 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); |
| 138 } | 138 } |
| 139 if (config.HasReceivedSocketReceiveBuffer()) { | 139 if (config.HasReceivedSocketReceiveBuffer()) { |
| 140 receive_buffer_bytes_ = | 140 receive_buffer_bytes_ = |
| 141 max(kMinSocketReceiveBuffer, | 141 max(kMinSocketReceiveBuffer, |
| 142 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); | 142 static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer())); |
| 143 } | 143 } |
| 144 send_algorithm_->SetFromConfig(config, is_server_); | 144 send_algorithm_->SetFromConfig(config, is_server_); |
| 145 | 145 |
| 146 if (network_change_visitor_ != nullptr) { | 146 if (network_change_visitor_ != nullptr) { |
| 147 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); | 147 network_change_visitor_->OnCongestionWindowChange(); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) { | 151 void QuicSentPacketManager::SetNumOpenStreams(size_t num_streams) { |
| 152 if (n_connection_simulation_) { | 152 if (n_connection_simulation_) { |
| 153 // Ensure the number of connections is between 1 and 5. | 153 // Ensure the number of connections is between 1 and 5. |
| 154 send_algorithm_->SetNumEmulatedConnections( | 154 send_algorithm_->SetNumEmulatedConnections( |
| 155 min<size_t>(5, max<size_t>(1, num_streams))); | 155 min<size_t>(5, max<size_t>(1, num_streams))); |
| 156 } | 156 } |
| 157 } | 157 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 void QuicSentPacketManager::MaybeInvokeCongestionEvent( | 230 void QuicSentPacketManager::MaybeInvokeCongestionEvent( |
| 231 bool rtt_updated, QuicByteCount bytes_in_flight) { | 231 bool rtt_updated, QuicByteCount bytes_in_flight) { |
| 232 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { | 232 if (!rtt_updated && packets_acked_.empty() && packets_lost_.empty()) { |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, | 235 send_algorithm_->OnCongestionEvent(rtt_updated, bytes_in_flight, |
| 236 packets_acked_, packets_lost_); | 236 packets_acked_, packets_lost_); |
| 237 packets_acked_.clear(); | 237 packets_acked_.clear(); |
| 238 packets_lost_.clear(); | 238 packets_lost_.clear(); |
| 239 if (network_change_visitor_ != nullptr) { | 239 if (network_change_visitor_ != nullptr) { |
| 240 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); | 240 network_change_visitor_->OnCongestionWindowChange(); |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 | 243 |
| 244 void QuicSentPacketManager::HandleAckForSentPackets( | 244 void QuicSentPacketManager::HandleAckForSentPackets( |
| 245 const QuicAckFrame& ack_frame) { | 245 const QuicAckFrame& ack_frame) { |
| 246 // Go through the packets we have not received an ack for and see if this | 246 // Go through the packets we have not received an ack for and see if this |
| 247 // incoming_ack shows they've been seen by the peer. | 247 // incoming_ack shows they've been seen by the peer. |
| 248 QuicTime::Delta delta_largest_observed = | 248 QuicTime::Delta delta_largest_observed = |
| 249 ack_frame.delta_time_largest_observed; | 249 ack_frame.delta_time_largest_observed; |
| 250 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); | 250 QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked(); |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 | 655 |
| 656 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted); | 656 send_algorithm_->OnRetransmissionTimeout(packets_retransmitted); |
| 657 if (packets_retransmitted) { | 657 if (packets_retransmitted) { |
| 658 if (consecutive_rto_count_ == 0) { | 658 if (consecutive_rto_count_ == 0) { |
| 659 first_rto_transmission_ = unacked_packets_.largest_sent_packet() + 1; | 659 first_rto_transmission_ = unacked_packets_.largest_sent_packet() + 1; |
| 660 } | 660 } |
| 661 ++consecutive_rto_count_; | 661 ++consecutive_rto_count_; |
| 662 } | 662 } |
| 663 | 663 |
| 664 if (network_change_visitor_ != nullptr) { | 664 if (network_change_visitor_ != nullptr) { |
| 665 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); | 665 network_change_visitor_->OnCongestionWindowChange(); |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 | 668 |
| 669 QuicSentPacketManager::RetransmissionTimeoutMode | 669 QuicSentPacketManager::RetransmissionTimeoutMode |
| 670 QuicSentPacketManager::GetRetransmissionMode() const { | 670 QuicSentPacketManager::GetRetransmissionMode() const { |
| 671 DCHECK(unacked_packets_.HasInFlightPackets()); | 671 DCHECK(unacked_packets_.HasInFlightPackets()); |
| 672 if (!handshake_confirmed_ && unacked_packets_.HasPendingCryptoPackets()) { | 672 if (!handshake_confirmed_ && unacked_packets_.HasPendingCryptoPackets()) { |
| 673 return HANDSHAKE_MODE; | 673 return HANDSHAKE_MODE; |
| 674 } | 674 } |
| 675 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) { | 675 if (loss_algorithm_->GetLossTimeout() != QuicTime::Zero()) { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as | 894 // Set up a pacing sender with a 1 millisecond alarm granularity, the same as |
| 895 // the default granularity of the Linux kernel's FQ qdisc. | 895 // the default granularity of the Linux kernel's FQ qdisc. |
| 896 using_pacing_ = true; | 896 using_pacing_ = true; |
| 897 send_algorithm_.reset( | 897 send_algorithm_.reset( |
| 898 new PacingSender(send_algorithm_.release(), | 898 new PacingSender(send_algorithm_.release(), |
| 899 QuicTime::Delta::FromMilliseconds(1), | 899 QuicTime::Delta::FromMilliseconds(1), |
| 900 kInitialUnpacedBurst)); | 900 kInitialUnpacedBurst)); |
| 901 } | 901 } |
| 902 | 902 |
| 903 } // namespace net | 903 } // namespace net |
| OLD | NEW |