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

Unified Diff: net/quic/quic_sent_packet_manager.cc

Issue 2125303002: Use overloaded operators with QuicTime for addition, subtraction and scalar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@126402784
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_received_packet_manager_test.cc ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_sent_packet_manager.cc
diff --git a/net/quic/quic_sent_packet_manager.cc b/net/quic/quic_sent_packet_manager.cc
index 832ca5d165948256eeb768ba8c1f991d75f42d32..7ec63fc2fb7f235abe1fe11bd6c7b559060f64f1 100644
--- a/net/quic/quic_sent_packet_manager.cc
+++ b/net/quic/quic_sent_packet_manager.cc
@@ -764,8 +764,7 @@ bool QuicSentPacketManager::MaybeUpdateRTT(const QuicAckFrame& ack_frame,
return false;
}
- QuicTime::Delta send_delta =
- ack_receive_time.Subtract(transmission_info.sent_time);
+ QuicTime::Delta send_delta = ack_receive_time - transmission_info.sent_time;
const int kMaxSendDeltaSeconds = 30;
if (FLAGS_quic_socket_walltimestamps &&
send_delta.ToSeconds() > kMaxSendDeltaSeconds) {
@@ -807,7 +806,7 @@ const QuicTime QuicSentPacketManager::GetRetransmissionTime() const {
}
switch (GetRetransmissionMode()) {
case HANDSHAKE_MODE:
- return clock_->ApproximateNow().Add(GetCryptoRetransmissionDelay());
+ return clock_->ApproximateNow() + GetCryptoRetransmissionDelay();
case LOSS_MODE:
return loss_algorithm_->GetLossTimeout();
case TLP_MODE: {
@@ -815,17 +814,17 @@ const QuicTime QuicSentPacketManager::GetRetransmissionTime() const {
// set the timer based on the earliest retransmittable packet.
// Base the updated timer on the send time of the last packet.
const QuicTime sent_time = unacked_packets_.GetLastPacketSentTime();
- const QuicTime tlp_time = sent_time.Add(GetTailLossProbeDelay());
+ const QuicTime tlp_time = sent_time + GetTailLossProbeDelay();
// Ensure the TLP timer never gets set to a time in the past.
return QuicTime::Max(clock_->ApproximateNow(), tlp_time);
}
case RTO_MODE: {
// The RTO is based on the first outstanding packet.
const QuicTime sent_time = unacked_packets_.GetLastPacketSentTime();
- QuicTime rto_time = sent_time.Add(GetRetransmissionDelay());
+ QuicTime rto_time = sent_time + GetRetransmissionDelay();
// Wait for TLP packets to be acked before an RTO fires.
QuicTime tlp_time =
- unacked_packets_.GetLastPacketSentTime().Add(GetTailLossProbeDelay());
+ unacked_packets_.GetLastPacketSentTime() + GetTailLossProbeDelay();
return QuicTime::Max(tlp_time, rto_time);
}
}
@@ -858,10 +857,9 @@ const QuicTime::Delta QuicSentPacketManager::GetTailLossProbeDelay() const {
static_cast<int64_t>(0.5 * srtt.ToMilliseconds())));
}
if (!unacked_packets_.HasMultipleInFlightPackets()) {
- return QuicTime::Delta::Max(
- srtt.Multiply(2),
- srtt.Multiply(1.5).Add(
- QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs / 2)));
+ return QuicTime::Delta::Max(2 * srtt,
+ 1.5 * srtt + QuicTime::Delta::FromMilliseconds(
+ kMinRetransmissionTimeMs / 2));
}
return QuicTime::Delta::FromMilliseconds(
max(kMinTailLossProbeTimeoutMs,
@@ -880,8 +878,9 @@ const QuicTime::Delta QuicSentPacketManager::GetRetransmissionDelay() const {
}
// Calculate exponential back off.
- retransmission_delay = retransmission_delay.Multiply(
- 1 << min<size_t>(consecutive_rto_count_, kMaxRetransmissions));
+ retransmission_delay =
+ retransmission_delay *
+ (1 << min<size_t>(consecutive_rto_count_, kMaxRetransmissions));
if (retransmission_delay.ToMilliseconds() > kMaxRetransmissionTimeMs) {
return QuicTime::Delta::FromMilliseconds(kMaxRetransmissionTimeMs);
« no previous file with comments | « net/quic/quic_received_packet_manager_test.cc ('k') | net/quic/quic_sent_packet_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698