| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 if (config.HasReceivedConnectionOptions() && | 121 if (config.HasReceivedConnectionOptions() && |
| 122 ContainsQuicTag(config.ReceivedConnectionOptions(), kPACE)) { | 122 ContainsQuicTag(config.ReceivedConnectionOptions(), kPACE)) { |
| 123 EnablePacing(); | 123 EnablePacing(); |
| 124 } | 124 } |
| 125 } else if (config.HasSendConnectionOptions() && | 125 } else if (config.HasSendConnectionOptions() && |
| 126 ContainsQuicTag(config.SendConnectionOptions(), kPACE)) { | 126 ContainsQuicTag(config.SendConnectionOptions(), kPACE)) { |
| 127 EnablePacing(); | 127 EnablePacing(); |
| 128 } | 128 } |
| 129 // TODO(ianswett): Remove the "HasReceivedLossDetection" branch once | 129 // TODO(ianswett): Remove the "HasReceivedLossDetection" branch once |
| 130 // the ConnectionOptions code is live everywhere. | 130 // the ConnectionOptions code is live everywhere. |
| 131 if ((config.HasReceivedLossDetection() && | 131 if (config.HasReceivedConnectionOptions() && |
| 132 config.ReceivedLossDetection() == kTIME) || | 132 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME)) { |
| 133 (config.HasReceivedConnectionOptions() && | |
| 134 ContainsQuicTag(config.ReceivedConnectionOptions(), kTIME))) { | |
| 135 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); | 133 loss_algorithm_.reset(LossDetectionInterface::Create(kTime)); |
| 136 } | 134 } |
| 137 send_algorithm_->SetFromConfig(config, is_server_); | 135 send_algorithm_->SetFromConfig(config, is_server_); |
| 138 | 136 |
| 139 if (network_change_visitor_ != NULL) { | 137 if (network_change_visitor_ != NULL) { |
| 140 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); | 138 network_change_visitor_->OnCongestionWindowChange(GetCongestionWindow()); |
| 141 } | 139 } |
| 142 } | 140 } |
| 143 | 141 |
| 144 // TODO(ianswett): Combine this method with OnPacketSent once packets are always | 142 // TODO(ianswett): Combine this method with OnPacketSent once packets are always |
| 145 // sent in order and the connection tracks RetransmittableFrames for longer. | 143 // sent in order and the connection tracks RetransmittableFrames for longer. |
| 146 void QuicSentPacketManager::OnSerializedPacket( | 144 void QuicSentPacketManager::OnSerializedPacket( |
| 147 const SerializedPacket& serialized_packet) { | 145 const SerializedPacket& serialized_packet) { |
| 148 if (serialized_packet.retransmittable_frames) { | 146 if (serialized_packet.retransmittable_frames) { |
| 149 ack_notifier_manager_.OnSerializedPacket(serialized_packet); | 147 ack_notifier_manager_.OnSerializedPacket(serialized_packet); |
| 150 } | 148 } |
| 151 unacked_packets_.AddPacket(serialized_packet); | 149 unacked_packets_.AddPacket(serialized_packet); |
| 152 | 150 |
| 153 if (debug_delegate_ != NULL) { | 151 if (debug_delegate_ != NULL) { |
| 152 // TODO(ianswett): Merge calls in the debug delegate. |
| 154 debug_delegate_->OnSerializedPacket(serialized_packet); | 153 debug_delegate_->OnSerializedPacket(serialized_packet); |
| 155 } | 154 } |
| 156 } | 155 } |
| 157 | 156 |
| 158 void QuicSentPacketManager::OnRetransmittedPacket( | 157 void QuicSentPacketManager::OnRetransmittedPacket( |
| 159 QuicPacketSequenceNumber old_sequence_number, | 158 QuicPacketSequenceNumber old_sequence_number, |
| 160 QuicPacketSequenceNumber new_sequence_number) { | 159 QuicPacketSequenceNumber new_sequence_number) { |
| 161 TransmissionType transmission_type; | 160 TransmissionType transmission_type; |
| 162 PendingRetransmissionMap::iterator it = | 161 PendingRetransmissionMap::iterator it = |
| 163 pending_retransmissions_.find(old_sequence_number); | 162 pending_retransmissions_.find(old_sequence_number); |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 bool QuicSentPacketManager::HasUnackedPackets() const { | 497 bool QuicSentPacketManager::HasUnackedPackets() const { |
| 499 return unacked_packets_.HasUnackedPackets(); | 498 return unacked_packets_.HasUnackedPackets(); |
| 500 } | 499 } |
| 501 | 500 |
| 502 QuicPacketSequenceNumber | 501 QuicPacketSequenceNumber |
| 503 QuicSentPacketManager::GetLeastUnacked() const { | 502 QuicSentPacketManager::GetLeastUnacked() const { |
| 504 return unacked_packets_.GetLeastUnacked(); | 503 return unacked_packets_.GetLeastUnacked(); |
| 505 } | 504 } |
| 506 | 505 |
| 507 bool QuicSentPacketManager::OnPacketSent( | 506 bool QuicSentPacketManager::OnPacketSent( |
| 508 QuicPacketSequenceNumber sequence_number, | 507 SerializedPacket* serialized_packet, |
| 508 QuicPacketSequenceNumber original_sequence_number, |
| 509 QuicTime sent_time, | 509 QuicTime sent_time, |
| 510 QuicByteCount bytes, | 510 QuicByteCount bytes, |
| 511 TransmissionType transmission_type, | 511 TransmissionType transmission_type, |
| 512 HasRetransmittableData has_retransmittable_data) { | 512 HasRetransmittableData has_retransmittable_data) { |
| 513 QuicPacketSequenceNumber sequence_number = serialized_packet->sequence_number; |
| 513 DCHECK_LT(0u, sequence_number); | 514 DCHECK_LT(0u, sequence_number); |
| 514 DCHECK(unacked_packets_.IsUnacked(sequence_number)); | 515 DCHECK(!unacked_packets_.IsUnacked(sequence_number)); |
| 515 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets."; | 516 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets."; |
| 517 if (original_sequence_number == 0) { |
| 518 OnSerializedPacket(*serialized_packet); |
| 519 serialized_packet->retransmittable_frames = NULL; |
| 520 } else { |
| 521 OnRetransmittedPacket(original_sequence_number, sequence_number); |
| 522 } |
| 523 |
| 516 if (pending_timer_transmission_count_ > 0) { | 524 if (pending_timer_transmission_count_ > 0) { |
| 517 --pending_timer_transmission_count_; | 525 --pending_timer_transmission_count_; |
| 518 } | 526 } |
| 519 | 527 |
| 520 if (unacked_packets_.bytes_in_flight() == 0) { | 528 if (unacked_packets_.bytes_in_flight() == 0) { |
| 521 // TODO(ianswett): Consider being less aggressive to force a new | 529 // TODO(ianswett): Consider being less aggressive to force a new |
| 522 // recent_min_rtt, likely by not discarding a relatively new sample. | 530 // recent_min_rtt, likely by not discarding a relatively new sample. |
| 523 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" | 531 DVLOG(1) << "Sampling a new recent min rtt within 2 samples. currently:" |
| 524 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms"; | 532 << rtt_stats_.recent_min_rtt().ToMilliseconds() << "ms"; |
| 525 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence); | 533 rtt_stats_.SampleNewRecentMinRtt(kNumMinRttSamplesAfterQuiescence); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 | 885 |
| 878 // Set up a pacing sender with a 5 millisecond alarm granularity. | 886 // Set up a pacing sender with a 5 millisecond alarm granularity. |
| 879 using_pacing_ = true; | 887 using_pacing_ = true; |
| 880 send_algorithm_.reset( | 888 send_algorithm_.reset( |
| 881 new PacingSender(send_algorithm_.release(), | 889 new PacingSender(send_algorithm_.release(), |
| 882 QuicTime::Delta::FromMilliseconds(5), | 890 QuicTime::Delta::FromMilliseconds(5), |
| 883 kInitialUnpacedBurst)); | 891 kInitialUnpacedBurst)); |
| 884 } | 892 } |
| 885 | 893 |
| 886 } // namespace net | 894 } // namespace net |
| OLD | NEW |