Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(798)

Side by Side Diff: net/quic/quic_sent_packet_manager.cc

Issue 288333002: Minor cleanup to simplify QuicSentPacketManager's OnPacketSent and (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 HasRetransmittableData has_retransmittable_data) { 438 HasRetransmittableData has_retransmittable_data) {
439 DCHECK_LT(0u, sequence_number); 439 DCHECK_LT(0u, sequence_number);
440 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets."; 440 LOG_IF(DFATAL, bytes == 0) << "Cannot send empty packets.";
441 // In rare circumstances, the packet could be serialized, sent, and then acked 441 // In rare circumstances, the packet could be serialized, sent, and then acked
442 // before OnPacketSent is called. 442 // before OnPacketSent is called.
443 if (!unacked_packets_.IsUnacked(sequence_number)) { 443 if (!unacked_packets_.IsUnacked(sequence_number)) {
444 return false; 444 return false;
445 } 445 }
446 446
447 // Only track packets as pending that the send algorithm wants us to track. 447 // Only track packets as pending that the send algorithm wants us to track.
448 if (!send_algorithm_->OnPacketSent(sent_time, 448 const bool pending =
449 unacked_packets_.bytes_in_flight(), 449 send_algorithm_->OnPacketSent(sent_time,
450 sequence_number, 450 unacked_packets_.bytes_in_flight(),
451 bytes, 451 sequence_number,
452 has_retransmittable_data)) { 452 bytes,
453 unacked_packets_.SetSent(sequence_number, sent_time, bytes, false); 453 has_retransmittable_data);
454 // Do not reset the retransmission timer, since the packet isn't tracked. 454 unacked_packets_.SetSent(sequence_number, sent_time, bytes, pending);
455 return false;
456 }
457 455
458 const bool set_retransmission_timer = !unacked_packets_.HasPendingPackets(); 456 // Reset the retransmission timer anytime a pending packet is sent.
459 457 return pending;
460 unacked_packets_.SetSent(sequence_number, sent_time, bytes, true);
461
462 // Reset the retransmission timer anytime a packet is sent in tail loss probe
463 // mode or before the crypto handshake has completed.
464 return set_retransmission_timer || GetRetransmissionMode() != RTO_MODE;
465 } 458 }
466 459
467 void QuicSentPacketManager::OnRetransmissionTimeout() { 460 void QuicSentPacketManager::OnRetransmissionTimeout() {
468 DCHECK(unacked_packets_.HasPendingPackets()); 461 DCHECK(unacked_packets_.HasPendingPackets());
469 // Handshake retransmission, timer based loss detection, TLP, and RTO are 462 // Handshake retransmission, timer based loss detection, TLP, and RTO are
470 // implemented with a single alarm. The handshake alarm is set when the 463 // implemented with a single alarm. The handshake alarm is set when the
471 // handshake has not completed, the loss alarm is set when the loss detection 464 // handshake has not completed, the loss alarm is set when the loss detection
472 // algorithm says to, and the TLP and RTO alarms are set after that. 465 // algorithm says to, and the TLP and RTO alarms are set after that.
473 // The TLP alarm is always set to run for under an RTO. 466 // The TLP alarm is always set to run for under an RTO.
474 switch (GetRetransmissionMode()) { 467 switch (GetRetransmissionMode()) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 return; 763 return;
771 } 764 }
772 765
773 using_pacing_ = true; 766 using_pacing_ = true;
774 send_algorithm_.reset( 767 send_algorithm_.reset(
775 new PacingSender(send_algorithm_.release(), 768 new PacingSender(send_algorithm_.release(),
776 QuicTime::Delta::FromMicroseconds(1))); 769 QuicTime::Delta::FromMicroseconds(1)));
777 } 770 }
778 771
779 } // namespace net 772 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698