Change delayed_ack_time to local_.. and peer...

Changes the name of delayed_ack_time_ to local_max_ack_delay_.
Add peer_max_ack_delay_, to be the delay that the peer is using.
This is a refactoring/etc in preparation of supporting the max ack
delay transport parameter negotiation for IETF QUIC.

gfe-relnote: N/A just a refactoring/name-change.
PiperOrigin-RevId: 258183470
Change-Id: I90d670b6a3d9516a224d6ef06f57d9111ffd1e2c
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index b693db7..5ef9720 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -1353,7 +1353,7 @@
         should_last_packet_instigate_acks_, last_decrypted_packet_level_,
         last_header_.packet_number, time_of_last_received_packet_,
         clock_->ApproximateNow(), sent_packet_manager_.GetRttStats(),
-        sent_packet_manager_.delayed_ack_time());
+        sent_packet_manager_.local_max_ack_delay());
   } else {
     QUIC_DLOG(INFO) << ENDPOINT << "Not updating ACK timeout for "
                     << QuicUtils::EncryptionLevelToString(
diff --git a/quic/core/quic_received_packet_manager.cc b/quic/core/quic_received_packet_manager.cc
index 39e4a92..2994748 100644
--- a/quic/core/quic_received_packet_manager.cc
+++ b/quic/core/quic_received_packet_manager.cc
@@ -219,7 +219,7 @@
     QuicTime time_of_last_received_packet,
     QuicTime now,
     const RttStats* rtt_stats,
-    QuicTime::Delta delayed_ack_time) {
+    QuicTime::Delta local_max_ack_delay) {
   if (!ack_frame_updated_) {
     // ACK frame has not been updated, nothing to do.
     return;
@@ -251,7 +251,7 @@
     // Wait for the minimum of the ack decimation delay or the delayed ack time
     // before sending an ack.
     QuicTime::Delta ack_delay = std::min(
-        delayed_ack_time, rtt_stats->min_rtt() * ack_decimation_delay_);
+        local_max_ack_delay, rtt_stats->min_rtt() * ack_decimation_delay_);
     if (fast_ack_after_quiescence_ && now - time_of_previous_received_packet_ >
                                           rtt_stats->SmoothedOrInitialRtt()) {
       // Ack the first packet out of queiscence faster, because QUIC does
@@ -273,7 +273,7 @@
       // or TLP packets, which we'd like to acknowledge quickly.
       MaybeUpdateAckTimeoutTo(now + QuicTime::Delta::FromMilliseconds(1));
     } else {
-      MaybeUpdateAckTimeoutTo(now + delayed_ack_time);
+      MaybeUpdateAckTimeoutTo(now + local_max_ack_delay);
     }
   }
 
diff --git a/quic/core/quic_received_packet_manager.h b/quic/core/quic_received_packet_manager.h
index c84054c..aaae7f1 100644
--- a/quic/core/quic_received_packet_manager.h
+++ b/quic/core/quic_received_packet_manager.h
@@ -65,7 +65,7 @@
                              QuicTime time_of_last_received_packet,
                              QuicTime now,
                              const RttStats* rtt_stats,
-                             QuicTime::Delta delayed_ack_time);
+                             QuicTime::Delta local_max_ack_delay);
 
   // Resets ACK related states, called after an ACK is successfully sent.
   void ResetAckStates();
diff --git a/quic/core/quic_sent_packet_manager.cc b/quic/core/quic_sent_packet_manager.cc
index e584310..d7c2c2b 100644
--- a/quic/core/quic_sent_packet_manager.cc
+++ b/quic/core/quic_sent_packet_manager.cc
@@ -111,7 +111,9 @@
       ietf_style_2x_tlp_(false),
       largest_mtu_acked_(0),
       handshake_confirmed_(false),
-      delayed_ack_time_(
+      local_max_ack_delay_(
+          QuicTime::Delta::FromMilliseconds(kDefaultDelayedAckTimeMs)),
+      peer_max_ack_delay_(
           QuicTime::Delta::FromMilliseconds(kDefaultDelayedAckTimeMs)),
       rtt_updated_(false),
       acked_packets_iter_(last_ack_frame_.packets.rbegin()),
@@ -148,7 +150,7 @@
     rtt_stats_.set_ignore_max_ack_delay(true);
   }
   if (config.HasClientSentConnectionOption(kMAD1, perspective)) {
-    rtt_stats_.set_initial_max_ack_delay(delayed_ack_time_);
+    rtt_stats_.set_initial_max_ack_delay(local_max_ack_delay_);
   }
   if (config.HasClientSentConnectionOption(kMAD2, perspective)) {
     min_tlp_timeout_ = QuicTime::Delta::Zero();
@@ -982,7 +984,7 @@
   if (conservative_handshake_retransmits_) {
     // Using the delayed ack time directly could cause conservative handshake
     // retransmissions to actually be more aggressive than the default.
-    delay_ms = std::max(delayed_ack_time_.ToMilliseconds(),
+    delay_ms = std::max(peer_max_ack_delay_.ToMilliseconds(),
                         static_cast<int64_t>(2 * srtt.ToMilliseconds()));
   } else {
     delay_ms = std::max(kMinHandshakeTimeoutMs,
diff --git a/quic/core/quic_sent_packet_manager.h b/quic/core/quic_sent_packet_manager.h
index 944c556..b90d977 100644
--- a/quic/core/quic_sent_packet_manager.h
+++ b/quic/core/quic_sent_packet_manager.h
@@ -353,12 +353,18 @@
     return pending_timer_transmission_count_;
   }
 
-  QuicTime::Delta delayed_ack_time() const { return delayed_ack_time_; }
+  QuicTime::Delta local_max_ack_delay() const { return local_max_ack_delay_; }
 
-  void set_delayed_ack_time(QuicTime::Delta delayed_ack_time) {
+  void set_local_max_ack_delay(QuicTime::Delta local_max_ack_delay) {
     // The delayed ack time should never be more than one half the min RTO time.
-    DCHECK_LE(delayed_ack_time, (min_rto_timeout_ * 0.5));
-    delayed_ack_time_ = delayed_ack_time;
+    DCHECK_LE(local_max_ack_delay, (min_rto_timeout_ * 0.5));
+    local_max_ack_delay_ = local_max_ack_delay;
+  }
+
+  QuicTime::Delta peer_max_ack_delay() const { return peer_max_ack_delay_; }
+
+  void set_peer_max_ack_delay(QuicTime::Delta peer_max_ack_delay) {
+    peer_max_ack_delay_ = peer_max_ack_delay;
   }
 
   const QuicUnackedPacketMap& unacked_packets() const {
@@ -604,9 +610,14 @@
   QuicPacketNumber
       largest_packets_peer_knows_is_acked_[NUM_PACKET_NUMBER_SPACES];
 
-  // The maximum amount of time to wait before sending an acknowledgement.
-  // The recovery code assumes the delayed ack time is the same on both sides.
-  QuicTime::Delta delayed_ack_time_;
+  // The local node's maximum ack delay time. This is the maximum amount of
+  // time to wait before sending an acknowledgement.
+  QuicTime::Delta local_max_ack_delay_;
+
+  // The maximum ACK delay time that the peer uses. Initialized to be the
+  // same as local_max_ack_delay_, may be changed via transport parameter
+  // negotiation.
+  QuicTime::Delta peer_max_ack_delay_;
 
   // Latest received ack frame.
   QuicAckFrame last_ack_frame_;
diff --git a/quic/core/uber_received_packet_manager.cc b/quic/core/uber_received_packet_manager.cc
index a3c79d3..6df7490 100644
--- a/quic/core/uber_received_packet_manager.cc
+++ b/quic/core/uber_received_packet_manager.cc
@@ -78,18 +78,18 @@
     QuicTime time_of_last_received_packet,
     QuicTime now,
     const RttStats* rtt_stats,
-    QuicTime::Delta delayed_ack_time) {
+    QuicTime::Delta local_max_ack_delay) {
   if (!supports_multiple_packet_number_spaces_) {
     received_packet_managers_[0].MaybeUpdateAckTimeout(
         should_last_packet_instigate_acks, last_received_packet_number,
-        time_of_last_received_packet, now, rtt_stats, delayed_ack_time);
+        time_of_last_received_packet, now, rtt_stats, local_max_ack_delay);
     return;
   }
   received_packet_managers_[QuicUtils::GetPacketNumberSpace(
                                 decrypted_packet_level)]
       .MaybeUpdateAckTimeout(
           should_last_packet_instigate_acks, last_received_packet_number,
-          time_of_last_received_packet, now, rtt_stats, delayed_ack_time);
+          time_of_last_received_packet, now, rtt_stats, local_max_ack_delay);
 }
 
 void UberReceivedPacketManager::ResetAckStates(
diff --git a/quic/core/uber_received_packet_manager.h b/quic/core/uber_received_packet_manager.h
index 21c2c0c..c442804 100644
--- a/quic/core/uber_received_packet_manager.h
+++ b/quic/core/uber_received_packet_manager.h
@@ -49,7 +49,7 @@
                              QuicTime time_of_last_received_packet,
                              QuicTime now,
                              const RttStats* rtt_stats,
-                             QuicTime::Delta delayed_ack_time);
+                             QuicTime::Delta local_max_ack_delay);
 
   // Resets ACK related states, called after an ACK is successfully sent.
   void ResetAckStates(EncryptionLevel encryption_level);
diff --git a/quic/quartc/quartc_factory.cc b/quic/quartc/quartc_factory.cc
index 53f046b..dab1a31 100644
--- a/quic/quartc/quartc_factory.cc
+++ b/quic/quartc/quartc_factory.cc
@@ -211,7 +211,9 @@
   // The p-time can go up to as high as 120ms, and when it does, it's
   // when the low overhead is the most important thing. Ideally it should be
   // above 120ms, but it cannot be higher than 0.5*RTO, which equals to 100ms.
-  sent_packet_manager.set_delayed_ack_time(
+  sent_packet_manager.set_local_max_ack_delay(
+      QuicTime::Delta::FromMilliseconds(100));
+  sent_packet_manager.set_peer_max_ack_delay(
       QuicTime::Delta::FromMilliseconds(100));
 
   quic_connection->set_fill_up_link_during_probing(true);