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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "net/quic/congestion_control/pacing_sender.h" | 9 #include "net/quic/congestion_control/pacing_sender.h" |
10 #include "net/quic/quic_ack_notifier_manager.h" | 10 #include "net/quic/quic_ack_notifier_manager.h" |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 return unacked_packets; | 543 return unacked_packets; |
544 } | 544 } |
545 | 545 |
546 bool QuicSentPacketManager::OnPacketSent( | 546 bool QuicSentPacketManager::OnPacketSent( |
547 QuicPacketSequenceNumber sequence_number, | 547 QuicPacketSequenceNumber sequence_number, |
548 QuicTime sent_time, | 548 QuicTime sent_time, |
549 QuicByteCount bytes, | 549 QuicByteCount bytes, |
550 TransmissionType transmission_type, | 550 TransmissionType transmission_type, |
551 HasRetransmittableData has_retransmittable_data) { | 551 HasRetransmittableData has_retransmittable_data) { |
552 DCHECK_LT(0u, sequence_number); | 552 DCHECK_LT(0u, sequence_number); |
553 DCHECK(ContainsKey(unacked_packets_, sequence_number)); | 553 // In some edge cases, on some platforms (such as Windows), it is possible |
554 // that we were write-blocked when we tried to send a packet, and then decided | |
555 // not to send the packet (such as when the encryption key changes, and we | |
556 // "discard" the unsent packet). In that rare case, we may indeed | |
557 // asynchronously (later) send the packet, calling this method, but the | |
558 // sequence number may already be erased from unacked_packets_ map. In that | |
559 // case, we can just return false since the packet will not be tracked for | |
560 // retransmission. | |
Ryan Hamilton
2014/01/10 05:22:46
Very clear. Awesome.
| |
561 if (!ContainsKey(unacked_packets_, sequence_number)) | |
562 return false; | |
554 DCHECK(!unacked_packets_[sequence_number].pending); | 563 DCHECK(!unacked_packets_[sequence_number].pending); |
555 if (has_retransmittable_data == HAS_RETRANSMITTABLE_DATA) { | |
556 DCHECK(unacked_packets_[sequence_number].retransmittable_frames); | |
Ryan Hamilton
2014/01/10 05:22:46
Is this DCHECK invalid? If so, why?
Ryan Hamilton
2014/01/10 05:24:25
Oh, it's in the CL description :>
Might be worth
jar (doing other things)
2014/01/10 05:36:43
Originally, I put a big comment in the code next t
| |
557 } | |
558 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number); | 564 UnackedPacketMap::iterator it = unacked_packets_.find(sequence_number); |
559 | 565 |
560 // Only track packets the send algorithm wants us to track. | 566 // Only track packets the send algorithm wants us to track. |
561 if (!send_algorithm_->OnPacketSent(sent_time, sequence_number, bytes, | 567 if (!send_algorithm_->OnPacketSent(sent_time, sequence_number, bytes, |
562 transmission_type, | 568 transmission_type, |
563 has_retransmittable_data)) { | 569 has_retransmittable_data)) { |
564 DCHECK(it->second.retransmittable_frames == NULL); | 570 DCHECK(it->second.retransmittable_frames == NULL); |
565 unacked_packets_.erase(it); | 571 unacked_packets_.erase(it); |
566 // Do not reset the retransmission timer, since the packet isn't tracked. | 572 // Do not reset the retransmission timer, since the packet isn't tracked. |
567 return false; | 573 return false; |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
991 } | 997 } |
992 previous_transmissions->erase(sequence_number); | 998 previous_transmissions->erase(sequence_number); |
993 if (previous_transmissions->size() == 1) { | 999 if (previous_transmissions->size() == 1) { |
994 QuicPacketSequenceNumber current = *previous_transmissions->begin(); | 1000 QuicPacketSequenceNumber current = *previous_transmissions->begin(); |
995 unacked_packets_[current].previous_transmissions = NULL; | 1001 unacked_packets_[current].previous_transmissions = NULL; |
996 delete previous_transmissions; | 1002 delete previous_transmissions; |
997 } | 1003 } |
998 } | 1004 } |
999 | 1005 |
1000 } // namespace net | 1006 } // namespace net |
OLD | NEW |