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

Unified Diff: net/quic/quic_connection.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_clock.cc ('k') | net/quic/quic_connection_logger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection.cc
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
index 134e286b982181bf62c0b64def340d0b8b84a309..31beab4841bb2dee470ff6125fc3108496a2702c 100644
--- a/net/quic/quic_connection.cc
+++ b/net/quic/quic_connection.cc
@@ -1065,10 +1065,9 @@ void QuicConnection::MaybeQueueAck(bool was_missing) {
} else if (!ack_alarm_->IsSet()) {
// Wait the minimum of a quarter min_rtt and the delayed ack time.
QuicTime::Delta ack_delay = QuicTime::Delta::Min(
- DelayedAckTime(),
- sent_packet_manager_->GetRttStats()->min_rtt().Multiply(
- ack_decimation_delay_));
- ack_alarm_->Set(clock_->ApproximateNow().Add(ack_delay));
+ DelayedAckTime(), sent_packet_manager_->GetRttStats()->min_rtt() *
+ ack_decimation_delay_);
+ ack_alarm_->Set(clock_->ApproximateNow() + ack_delay);
}
} else {
// Ack with a timer or every 2 packets by default.
@@ -1076,7 +1075,7 @@ void QuicConnection::MaybeQueueAck(bool was_missing) {
kDefaultRetransmittablePacketsBeforeAck) {
ack_queued_ = true;
} else if (!ack_alarm_->IsSet()) {
- ack_alarm_->Set(clock_->ApproximateNow().Add(DelayedAckTime()));
+ ack_alarm_->Set(clock_->ApproximateNow() + DelayedAckTime());
}
}
@@ -1084,8 +1083,9 @@ void QuicConnection::MaybeQueueAck(bool was_missing) {
if (received_packet_manager_.HasNewMissingPackets()) {
if (ack_mode_ == ACK_DECIMATION_WITH_REORDERING) {
// Wait the minimum of an eighth min_rtt and the existing ack time.
- QuicTime ack_time = clock_->ApproximateNow().Add(
- sent_packet_manager_->GetRttStats()->min_rtt().Multiply(0.125));
+ QuicTime ack_time =
+ clock_->ApproximateNow() +
+ 0.125 * sent_packet_manager_->GetRttStats()->min_rtt();
if (!ack_alarm_->IsSet() || ack_alarm_->deadline() > ack_time) {
ack_alarm_->Cancel();
ack_alarm_->Set(ack_time);
@@ -1578,7 +1578,7 @@ bool QuicConnection::CanWrite(HasRetransmittableData retransmittable) {
DCHECK_NE(kInvalidPathId, path_id);
// If the scheduler requires a delay, then we can not send this packet now.
if (!delay.IsZero()) {
- send_alarm_->Update(now.Add(delay), QuicTime::Delta::FromMilliseconds(1));
+ send_alarm_->Update(now + delay, QuicTime::Delta::FromMilliseconds(1));
DVLOG(1) << ENDPOINT << "Delaying sending " << delay.ToMilliseconds()
<< "ms";
return false;
@@ -2141,9 +2141,9 @@ void QuicConnection::SetNetworkTimeouts(QuicTime::Delta handshake_timeout,
// Adjust the idle timeout on client and server to prevent clients from
// sending requests to servers which have already closed the connection.
if (perspective_ == Perspective::IS_SERVER) {
- idle_timeout = idle_timeout.Add(QuicTime::Delta::FromSeconds(3));
+ idle_timeout = idle_timeout + QuicTime::Delta::FromSeconds(3);
} else if (idle_timeout > QuicTime::Delta::FromSeconds(1)) {
- idle_timeout = idle_timeout.Subtract(QuicTime::Delta::FromSeconds(1));
+ idle_timeout = idle_timeout - QuicTime::Delta::FromSeconds(1);
}
handshake_timeout_ = handshake_timeout;
idle_network_timeout_ = idle_timeout;
@@ -2159,7 +2159,7 @@ void QuicConnection::CheckForTimeout() {
// |delta| can be < 0 as |now| is approximate time but |time_of_last_packet|
// is accurate time. However, this should not change the behavior of
// timeout handling.
- QuicTime::Delta idle_duration = now.Subtract(time_of_last_packet);
+ QuicTime::Delta idle_duration = now - time_of_last_packet;
DVLOG(1) << ENDPOINT << "last packet "
<< time_of_last_packet.ToDebuggingValue()
<< " now:" << now.ToDebuggingValue()
@@ -2175,8 +2175,7 @@ void QuicConnection::CheckForTimeout() {
}
if (!handshake_timeout_.IsInfinite()) {
- QuicTime::Delta connected_duration =
- now.Subtract(stats_.connection_creation_time);
+ QuicTime::Delta connected_duration = now - stats_.connection_creation_time;
DVLOG(1) << ENDPOINT
<< "connection time: " << connected_duration.ToMicroseconds()
<< " handshake timeout: " << handshake_timeout_.ToMicroseconds();
@@ -2196,10 +2195,10 @@ void QuicConnection::SetTimeoutAlarm() {
QuicTime time_of_last_packet =
max(time_of_last_received_packet_, time_of_last_sent_new_packet_);
- QuicTime deadline = time_of_last_packet.Add(idle_network_timeout_);
+ QuicTime deadline = time_of_last_packet + idle_network_timeout_;
if (!handshake_timeout_.IsInfinite()) {
deadline =
- min(deadline, stats_.connection_creation_time.Add(handshake_timeout_));
+ min(deadline, stats_.connection_creation_time + handshake_timeout_);
}
timeout_alarm_->Cancel();
@@ -2217,7 +2216,7 @@ void QuicConnection::SetPingAlarm() {
return;
}
QuicTime::Delta ping_timeout = QuicTime::Delta::FromSeconds(kPingTimeoutSecs);
- ping_alarm_->Update(clock_->ApproximateNow().Add(ping_timeout),
+ ping_alarm_->Update(clock_->ApproximateNow() + ping_timeout,
QuicTime::Delta::FromSeconds(1));
}
« no previous file with comments | « net/quic/quic_clock.cc ('k') | net/quic/quic_connection_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698