Move local_delayed_ack_time from QuicSentPacketManager to QuicReceivedPacketManager, set the delayed ack time to 1ms for Initial and Handshake packet number spaces when using v99, and use peer_delayed_ack_time instead of local_delayed_ack_time when with the MAD1 connection option.

gfe-relnote: n/a (Refactor or v99 only)
PiperOrigin-RevId: 261378188
Change-Id: I4bfed0bde6fa58506250b766294221f1aaf9fc29
diff --git a/quic/core/uber_received_packet_manager.cc b/quic/core/uber_received_packet_manager.cc
index 6df7490..78cf359 100644
--- a/quic/core/uber_received_packet_manager.cc
+++ b/quic/core/uber_received_packet_manager.cc
@@ -4,6 +4,7 @@
 
 #include "net/third_party/quiche/src/quic/core/uber_received_packet_manager.h"
 
+#include "net/third_party/quiche/src/quic/core/quic_types.h"
 #include "net/third_party/quiche/src/quic/core/quic_utils.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
 
@@ -77,19 +78,18 @@
     QuicPacketNumber last_received_packet_number,
     QuicTime time_of_last_received_packet,
     QuicTime now,
-    const RttStats* rtt_stats,
-    QuicTime::Delta local_max_ack_delay) {
+    const RttStats* rtt_stats) {
   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, local_max_ack_delay);
+        time_of_last_received_packet, now, rtt_stats);
     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, local_max_ack_delay);
+      .MaybeUpdateAckTimeout(should_last_packet_instigate_acks,
+                             last_received_packet_number,
+                             time_of_last_received_packet, now, rtt_stats);
 }
 
 void UberReceivedPacketManager::ResetAckStates(
@@ -112,6 +112,12 @@
                 "packet has been received.";
     return;
   }
+  // In IETF QUIC, the peer is expected to acknowledge packets in Initial and
+  // Handshake packets with minimal delay.
+  received_packet_managers_[INITIAL_DATA].set_local_max_ack_delay(
+      QuicTime::Delta::FromMilliseconds(1));
+  received_packet_managers_[HANDSHAKE_DATA].set_local_max_ack_delay(
+      QuicTime::Delta::FromMilliseconds(1));
 
   supports_multiple_packet_number_spaces_ = true;
 }
@@ -207,6 +213,23 @@
   }
 }
 
+QuicTime::Delta UberReceivedPacketManager::max_ack_delay() {
+  if (!supports_multiple_packet_number_spaces_) {
+    return received_packet_managers_[0].local_max_ack_delay();
+  }
+  return received_packet_managers_[APPLICATION_DATA].local_max_ack_delay();
+}
+
+void UberReceivedPacketManager::set_max_ack_delay(
+    QuicTime::Delta max_ack_delay) {
+  if (!supports_multiple_packet_number_spaces_) {
+    received_packet_managers_[0].set_local_max_ack_delay(max_ack_delay);
+    return;
+  }
+  received_packet_managers_[APPLICATION_DATA].set_local_max_ack_delay(
+      max_ack_delay);
+}
+
 void UberReceivedPacketManager::set_save_timestamps(bool save_timestamps) {
   for (auto& received_packet_manager : received_packet_managers_) {
     received_packet_manager.set_save_timestamps(save_timestamps);