Add a QUIC protocol flag to enable or disable defer_send_in_response_to_packets in GFE and uStreamer.

Protected by FLAGS_quic_reloadable_flag_quic_dont_defer_sending.

PiperOrigin-RevId: 346802811
Change-Id: I178794f3cc4ee6b2ac5570c9c8be400bc4abdd4f
diff --git a/quic/core/crypto/crypto_protocol.h b/quic/core/crypto/crypto_protocol.h
index 9b09027..d0420cc 100644
--- a/quic/core/crypto/crypto_protocol.h
+++ b/quic/core/crypto/crypto_protocol.h
@@ -270,6 +270,9 @@
 const QuicTag kNCMR = TAG('N', 'C', 'M', 'R');   // Do not attempt connection
                                                  // migration.
 
+// Allows disabling defer_send_in_response_to_packets in QuicConnection.
+const QuicTag kDFER = TAG('D', 'F', 'E', 'R');   // Do not defer sending.
+
 // Disable Pacing offload option.
 const QuicTag kNPCO = TAG('N', 'P', 'C', 'O');    // No pacing offload.
 
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 8f1fd4b..9c49fef 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -672,6 +672,11 @@
   if (config.HasClientSentConnectionOption(kEACK, perspective_)) {
     bundle_retransmittable_with_pto_ack_ = true;
   }
+  if (GetQuicReloadableFlag(quic_dont_defer_sending) &&
+      config.HasClientSentConnectionOption(kDFER, perspective_)) {
+    QUIC_RELOADABLE_FLAG_COUNT(quic_dont_defer_sending);
+    defer_send_in_response_to_packets_ = false;
+  }
   if (config.HasReceivedMaxPacketSize()) {
     peer_max_packet_size_ = config.ReceivedMaxPacketSize();
     MaybeUpdatePacketCreatorMaxPacketLengthAndPadding();
diff --git a/quic/core/quic_flags_list.h b/quic/core/quic_flags_list.h
index d5f27e6..28082aa 100644
--- a/quic/core/quic_flags_list.h
+++ b/quic/core/quic_flags_list.h
@@ -33,6 +33,7 @@
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_discard_initial_packet_with_key_dropped, true)
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_do_not_clip_received_error_code, true)
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_donot_reset_ideal_next_packet_send_time, false)
+QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_dont_defer_sending, false)
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_mtu_discovery_at_server, false)
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_server_on_wire_ping, false)
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_enable_token_based_address_validation, false)
diff --git a/quic/core/quic_protocol_flags_list.h b/quic/core/quic_protocol_flags_list.h
index b9d0a2d..14ed8cd 100644
--- a/quic/core/quic_protocol_flags_list.h
+++ b/quic/core/quic_protocol_flags_list.h
@@ -243,4 +243,9 @@
                    "If true, QUIC server will disable TLS resumption by not "
                    "issuing or processing session tickets.")
 
+QUIC_PROTOCOL_FLAG(bool,
+                   quic_defer_send_in_response,
+                   true,
+                   "If true, QUIC servers will defer sending in response to "
+                   "incoming packets by default.")
 #endif