In quic, coalesce packet of higher encryption level with initial or handshake retransmission. protected by gfe2_reloadable_flag_quic_coalesced_packet_of_higher_space.

The goal of this change is to mitigate inflated RTT sample.

PiperOrigin-RevId: 321556627
Change-Id: I7fc8675bb0f05a48b6e81ed4aa9c04b42fb0690a
diff --git a/quic/core/quic_packet_creator.cc b/quic/core/quic_packet_creator.cc
index 066763a..131ef5e 100644
--- a/quic/core/quic_packet_creator.cc
+++ b/quic/core/quic_packet_creator.cc
@@ -203,6 +203,9 @@
     // Please note: this would not guarantee to fit next packet if the size of
     // packet header increases (e.g., encryption level changes).
     QUIC_DLOG(INFO) << length << " is too small to fit packet header";
+    if (coalesced_packet_of_higher_space_) {
+      RemoveSoftMaxPacketLength();
+    }
     return;
   }
   QUIC_DVLOG(1) << "Setting soft max packet length to: " << length;
@@ -2018,5 +2021,9 @@
   return flusher_attached_;
 }
 
+bool QuicPacketCreator::HasSoftMaxPacketLength() const {
+  return latched_hard_max_packet_length_ != 0;
+}
+
 #undef ENDPOINT  // undef for jumbo builds
 }  // namespace quic