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