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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 330 |
331 const TransmissionInfo& transmission_info = | 331 const TransmissionInfo& transmission_info = |
332 unacked_packets_.GetTransmissionInfo(sequence_number); | 332 unacked_packets_.GetTransmissionInfo(sequence_number); |
333 // The AckNotifierManager needs to be notified for revived packets, | 333 // The AckNotifierManager needs to be notified for revived packets, |
334 // since it indicates the packet arrived from the appliction's perspective. | 334 // since it indicates the packet arrived from the appliction's perspective. |
335 if (transmission_info.retransmittable_frames) { | 335 if (transmission_info.retransmittable_frames) { |
336 ack_notifier_manager_.OnPacketAcked( | 336 ack_notifier_manager_.OnPacketAcked( |
337 sequence_number, delta_largest_observed); | 337 sequence_number, delta_largest_observed); |
338 } | 338 } |
339 | 339 |
340 unacked_packets_.NeuterIfPendingOrRemovePacket(sequence_number); | 340 if (!transmission_info.pending) { |
| 341 unacked_packets_.RemovePacket(sequence_number); |
| 342 } else { |
| 343 unacked_packets_.NeuterPacket(sequence_number); |
| 344 } |
341 } | 345 } |
342 | 346 |
343 QuicUnackedPacketMap::const_iterator QuicSentPacketManager::MarkPacketHandled( | 347 QuicUnackedPacketMap::const_iterator QuicSentPacketManager::MarkPacketHandled( |
344 QuicPacketSequenceNumber sequence_number, | 348 QuicPacketSequenceNumber sequence_number, |
345 QuicTime::Delta delta_largest_observed) { | 349 QuicTime::Delta delta_largest_observed) { |
346 if (!unacked_packets_.IsUnacked(sequence_number)) { | 350 if (!unacked_packets_.IsUnacked(sequence_number)) { |
347 LOG(DFATAL) << "Packet is not unacked: " << sequence_number; | 351 LOG(DFATAL) << "Packet is not unacked: " << sequence_number; |
348 return unacked_packets_.end(); | 352 return unacked_packets_.end(); |
349 } | 353 } |
350 const TransmissionInfo& transmission_info = | 354 const TransmissionInfo& transmission_info = |
(...skipping 14 matching lines...) Expand all Loading... |
365 | 369 |
366 // The AckNotifierManager needs to be notified about the most recent | 370 // The AckNotifierManager needs to be notified about the most recent |
367 // transmission, since that's the one only one it tracks. | 371 // transmission, since that's the one only one it tracks. |
368 ack_notifier_manager_.OnPacketAcked(newest_transmission, | 372 ack_notifier_manager_.OnPacketAcked(newest_transmission, |
369 delta_largest_observed); | 373 delta_largest_observed); |
370 | 374 |
371 bool has_crypto_handshake = HasCryptoHandshake( | 375 bool has_crypto_handshake = HasCryptoHandshake( |
372 unacked_packets_.GetTransmissionInfo(newest_transmission)); | 376 unacked_packets_.GetTransmissionInfo(newest_transmission)); |
373 while (all_transmissions_it != all_transmissions.rend()) { | 377 while (all_transmissions_it != all_transmissions.rend()) { |
374 QuicPacketSequenceNumber previous_transmission = *all_transmissions_it; | 378 QuicPacketSequenceNumber previous_transmission = *all_transmissions_it; |
| 379 const TransmissionInfo& transmission_info = |
| 380 unacked_packets_.GetTransmissionInfo(previous_transmission); |
375 // If this packet was marked for retransmission, don't bother retransmitting | 381 // If this packet was marked for retransmission, don't bother retransmitting |
376 // it anymore. | 382 // it anymore. |
377 pending_retransmissions_.erase(previous_transmission); | 383 pending_retransmissions_.erase(previous_transmission); |
378 if (has_crypto_handshake) { | 384 if (has_crypto_handshake) { |
379 // If it's a crypto handshake packet, discard it and all retransmissions, | 385 // If it's a crypto handshake packet, discard it and all retransmissions, |
380 // since they won't be acked now that one has been processed. | 386 // since they won't be acked now that one has been processed. |
381 unacked_packets_.SetNotPending(previous_transmission); | 387 unacked_packets_.SetNotPending(previous_transmission); |
382 } | 388 } |
383 unacked_packets_.NeuterIfPendingOrRemovePacket(previous_transmission); | 389 if (!transmission_info.pending) { |
| 390 unacked_packets_.RemovePacket(previous_transmission); |
| 391 } else { |
| 392 unacked_packets_.NeuterPacket(previous_transmission); |
| 393 } |
384 ++all_transmissions_it; | 394 ++all_transmissions_it; |
385 } | 395 } |
386 | 396 |
387 QuicUnackedPacketMap::const_iterator next_unacked = unacked_packets_.begin(); | 397 QuicUnackedPacketMap::const_iterator next_unacked = unacked_packets_.begin(); |
388 while (next_unacked != unacked_packets_.end() && | 398 while (next_unacked != unacked_packets_.end() && |
389 next_unacked->first < sequence_number) { | 399 next_unacked->first < sequence_number) { |
390 ++next_unacked; | 400 ++next_unacked; |
391 } | 401 } |
392 return next_unacked; | 402 return next_unacked; |
393 } | 403 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 packets_lost_[sequence_number] = transmission_info; | 594 packets_lost_[sequence_number] = transmission_info; |
585 unacked_packets_.SetNotPending(sequence_number); | 595 unacked_packets_.SetNotPending(sequence_number); |
586 | 596 |
587 if (transmission_info.retransmittable_frames != NULL) { | 597 if (transmission_info.retransmittable_frames != NULL) { |
588 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION); | 598 MarkForRetransmission(sequence_number, LOSS_RETRANSMISSION); |
589 } else { | 599 } else { |
590 // Since we will not retransmit this, we need to remove it from | 600 // Since we will not retransmit this, we need to remove it from |
591 // unacked_packets_. This is either the current transmission of | 601 // unacked_packets_. This is either the current transmission of |
592 // a packet whose previous transmission has been acked, or it | 602 // a packet whose previous transmission has been acked, or it |
593 // is a packet that has been TLP retransmitted. | 603 // is a packet that has been TLP retransmitted. |
594 unacked_packets_.NeuterIfPendingOrRemovePacket(sequence_number); | 604 unacked_packets_.RemovePacket(sequence_number); |
595 } | 605 } |
596 } | 606 } |
597 } | 607 } |
598 | 608 |
599 bool QuicSentPacketManager::MaybeUpdateRTT( | 609 bool QuicSentPacketManager::MaybeUpdateRTT( |
600 const ReceivedPacketInfo& received_info, | 610 const ReceivedPacketInfo& received_info, |
601 const QuicTime& ack_receive_time) { | 611 const QuicTime& ack_receive_time) { |
602 if (!unacked_packets_.IsUnacked(received_info.largest_observed)) { | 612 if (!unacked_packets_.IsUnacked(received_info.largest_observed)) { |
603 return false; | 613 return false; |
604 } | 614 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 return; | 756 return; |
747 } | 757 } |
748 | 758 |
749 using_pacing_ = true; | 759 using_pacing_ = true; |
750 send_algorithm_.reset( | 760 send_algorithm_.reset( |
751 new PacingSender(send_algorithm_.release(), | 761 new PacingSender(send_algorithm_.release(), |
752 QuicTime::Delta::FromMicroseconds(1))); | 762 QuicTime::Delta::FromMicroseconds(1))); |
753 } | 763 } |
754 | 764 |
755 } // namespace net | 765 } // namespace net |
OLD | NEW |