| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 continue; | 197 continue; |
| 198 } | 198 } |
| 199 | 199 |
| 200 // Packet was acked, so remove it from our unacked packet list. | 200 // Packet was acked, so remove it from our unacked packet list. |
| 201 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number; | 201 DVLOG(1) << ENDPOINT << "Got an ack for packet " << sequence_number; |
| 202 // If data is associated with the most recent transmission of this | 202 // If data is associated with the most recent transmission of this |
| 203 // packet, then inform the caller. | 203 // packet, then inform the caller. |
| 204 if (it->second.pending) { | 204 if (it->second.pending) { |
| 205 packets_acked_[sequence_number] = it->second; | 205 packets_acked_[sequence_number] = it->second; |
| 206 } | 206 } |
| 207 it = MarkPacketHandled(sequence_number, delta_largest_observed); | 207 it = MarkPacketHandled(it, delta_largest_observed); |
| 208 } | 208 } |
| 209 | 209 |
| 210 // Discard any retransmittable frames associated with revived packets. | 210 // Discard any retransmittable frames associated with revived packets. |
| 211 for (SequenceNumberSet::const_iterator revived_it = | 211 for (SequenceNumberSet::const_iterator revived_it = |
| 212 received_info.revived_packets.begin(); | 212 received_info.revived_packets.begin(); |
| 213 revived_it != received_info.revived_packets.end(); ++revived_it) { | 213 revived_it != received_info.revived_packets.end(); ++revived_it) { |
| 214 MarkPacketRevived(*revived_it, delta_largest_observed); | 214 MarkPacketRevived(*revived_it, delta_largest_observed); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool QuicSentPacketManager::HasRetransmittableFrames( | 218 bool QuicSentPacketManager::HasRetransmittableFrames( |
| 219 QuicPacketSequenceNumber sequence_number) const { | 219 QuicPacketSequenceNumber sequence_number) const { |
| 220 return unacked_packets_.HasRetransmittableFrames(sequence_number); | 220 return unacked_packets_.HasRetransmittableFrames(sequence_number); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void QuicSentPacketManager::RetransmitUnackedPackets( | 223 void QuicSentPacketManager::RetransmitUnackedPackets( |
| 224 RetransmissionType retransmission_type) { | 224 RetransmissionType retransmission_type) { |
| 225 QuicUnackedPacketMap::const_iterator unacked_it = unacked_packets_.begin(); | 225 QuicUnackedPacketMap::const_iterator unacked_it = unacked_packets_.begin(); |
| 226 while (unacked_it != unacked_packets_.end()) { | 226 while (unacked_it != unacked_packets_.end()) { |
| 227 const RetransmittableFrames* frames = | 227 const RetransmittableFrames* frames = |
| 228 unacked_it->second.retransmittable_frames; | 228 unacked_it->second.retransmittable_frames; |
| 229 // Only mark it as handled if it can't be retransmitted and there are no | |
| 230 // pending retransmissions which would be cleared. | |
| 231 if (frames == NULL && unacked_it->second.all_transmissions->size() == 1 && | |
| 232 retransmission_type == ALL_PACKETS) { | |
| 233 unacked_it = MarkPacketHandled(unacked_it->first, | |
| 234 QuicTime::Delta::Zero()); | |
| 235 continue; | |
| 236 } | |
| 237 // If it had no other transmissions, we handle it above. If it has | |
| 238 // other transmissions, one of them must have retransmittable frames, | |
| 239 // so that gets resolved the same way as other retransmissions. | |
| 240 // TODO(ianswett): Consider adding a new retransmission type which removes | 229 // TODO(ianswett): Consider adding a new retransmission type which removes |
| 241 // all these old packets from unacked and retransmits them as new sequence | 230 // all these old packets from unacked and retransmits them as new sequence |
| 242 // numbers with no connection to the previous ones. | 231 // numbers with no connection to the previous ones. |
| 243 if (frames != NULL && (retransmission_type == ALL_PACKETS || | 232 if (frames != NULL && (retransmission_type == ALL_PACKETS || |
| 244 frames->encryption_level() == ENCRYPTION_INITIAL)) { | 233 frames->encryption_level() == ENCRYPTION_INITIAL)) { |
| 245 MarkForRetransmission(unacked_it->first, ALL_UNACKED_RETRANSMISSION); | 234 MarkForRetransmission(unacked_it->first, ALL_UNACKED_RETRANSMISSION); |
| 246 } | 235 } |
| 247 ++unacked_it; | 236 ++unacked_it; |
| 248 } | 237 } |
| 249 } | 238 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // since it indicates the packet arrived from the appliction's perspective. | 325 // since it indicates the packet arrived from the appliction's perspective. |
| 337 if (transmission_info.retransmittable_frames) { | 326 if (transmission_info.retransmittable_frames) { |
| 338 ack_notifier_manager_.OnPacketAcked( | 327 ack_notifier_manager_.OnPacketAcked( |
| 339 newest_transmission, delta_largest_observed); | 328 newest_transmission, delta_largest_observed); |
| 340 } | 329 } |
| 341 | 330 |
| 342 unacked_packets_.RemoveRetransmittability(sequence_number, largest_observed_); | 331 unacked_packets_.RemoveRetransmittability(sequence_number, largest_observed_); |
| 343 } | 332 } |
| 344 | 333 |
| 345 QuicUnackedPacketMap::const_iterator QuicSentPacketManager::MarkPacketHandled( | 334 QuicUnackedPacketMap::const_iterator QuicSentPacketManager::MarkPacketHandled( |
| 346 QuicPacketSequenceNumber sequence_number, | 335 QuicUnackedPacketMap::const_iterator it, |
| 347 QuicTime::Delta delta_largest_observed) { | 336 QuicTime::Delta delta_largest_observed) { |
| 348 if (!unacked_packets_.IsUnacked(sequence_number)) { | 337 LOG_IF(DFATAL, it == unacked_packets_.end()) |
| 349 LOG(DFATAL) << "Packet is not unacked: " << sequence_number; | 338 << "MarkPacketHandled must be passed a valid iterator entry."; |
| 350 return unacked_packets_.end(); | 339 const QuicPacketSequenceNumber sequence_number = it->first; |
| 351 } | 340 const TransmissionInfo& transmission_info = it->second; |
| 352 const TransmissionInfo& transmission_info = | |
| 353 unacked_packets_.GetTransmissionInfo(sequence_number); | |
| 354 | 341 |
| 355 QuicPacketSequenceNumber newest_transmission = | 342 QuicPacketSequenceNumber newest_transmission = |
| 356 *transmission_info.all_transmissions->rbegin(); | 343 *transmission_info.all_transmissions->rbegin(); |
| 357 // Remove the most recent packet, if it is pending retransmission. | 344 // Remove the most recent packet, if it is pending retransmission. |
| 358 pending_retransmissions_.erase(newest_transmission); | 345 pending_retransmissions_.erase(newest_transmission); |
| 359 | 346 |
| 360 // Two cases for MarkPacketHandled: | 347 // Two cases for MarkPacketHandled: |
| 361 // 1) Handle the most recent or a crypto packet, so remove all transmissions. | 348 // 1) Handle the most recent or a crypto packet, so remove all transmissions. |
| 362 // 2) Handle old transmission, keep all other pending transmissions, | 349 // 2) Handle old transmission, keep all other pending transmissions, |
| 363 // but disassociate them from one another. | 350 // but disassociate them from one another. |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 return; | 734 return; |
| 748 } | 735 } |
| 749 | 736 |
| 750 using_pacing_ = true; | 737 using_pacing_ = true; |
| 751 send_algorithm_.reset( | 738 send_algorithm_.reset( |
| 752 new PacingSender(send_algorithm_.release(), | 739 new PacingSender(send_algorithm_.release(), |
| 753 QuicTime::Delta::FromMicroseconds(1))); | 740 QuicTime::Delta::FromMicroseconds(1))); |
| 754 } | 741 } |
| 755 | 742 |
| 756 } // namespace net | 743 } // namespace net |
| OLD | NEW |