Deprecate gfe2_reloadable_flag_quic_donot_write_mid_packet_processing.

PiperOrigin-RevId: 387569747
diff --git a/quic/core/http/end_to_end_test.cc b/quic/core/http/end_to_end_test.cc
index 913b5b2..e64d8e6 100644
--- a/quic/core/http/end_to_end_test.cc
+++ b/quic/core/http/end_to_end_test.cc
@@ -1882,11 +1882,6 @@
 
   ON_CALL(visitor, OnZeroRttRejected(_)).WillByDefault(Invoke([this]() {
     EXPECT_FALSE(GetClientSession()->IsEncryptionEstablished());
-    if (!GetQuicReloadableFlag(quic_donot_write_mid_packet_processing)) {
-      // Trigger an OnCanWrite() to make sure no unencrypted data will be
-      // written.
-      GetClientSession()->OnCanWrite();
-    }
   }));
 
   // The 0-RTT handshake should fail.
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index a45f7db..d3b3e82 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -2925,9 +2925,7 @@
     }
   }
 
-  const bool processed = MaybeProcessCoalescedPackets();
-  if (!donot_write_mid_packet_processing_ || !processed) {
-    QUIC_RELOADABLE_FLAG_COUNT_N(quic_donot_write_mid_packet_processing, 3, 3);
+  if (!MaybeProcessCoalescedPackets()) {
     MaybeProcessUndecryptablePackets();
     MaybeSendInResponseToPacket();
   }
@@ -3008,7 +3006,7 @@
 }
 
 void QuicConnection::WriteIfNotBlocked() {
-  if (donot_write_mid_packet_processing_ && framer().is_processing_packet()) {
+  if (framer().is_processing_packet()) {
     QUIC_BUG(connection_write_mid_packet_processing)
         << ENDPOINT << "Tried to write in mid of packet processing";
     return;
@@ -4586,11 +4584,7 @@
   }
   if (processed) {
     MaybeProcessUndecryptablePackets();
-    if (donot_write_mid_packet_processing_) {
-      QUIC_RELOADABLE_FLAG_COUNT_N(quic_donot_write_mid_packet_processing, 2,
-                                   3);
-      MaybeSendInResponseToPacket();
-    }
+    MaybeSendInResponseToPacket();
   }
   return processed;
 }
diff --git a/quic/core/quic_connection.h b/quic/core/quic_connection.h
index 2409c76..dea513a 100644
--- a/quic/core/quic_connection.h
+++ b/quic/core/quic_connection.h
@@ -1244,10 +1244,6 @@
   // Instantiates connection ID manager.
   void CreateConnectionIdManager();
 
-  bool donot_write_mid_packet_processing() const {
-    return donot_write_mid_packet_processing_;
-  }
-
   QuicConnectionContext* context() { return &context_; }
   const QuicConnectionContext* context() const { return &context_; }
 
@@ -2264,9 +2260,6 @@
 
   bool support_multiple_connection_ids_ = false;
 
-  const bool donot_write_mid_packet_processing_ =
-      GetQuicReloadableFlag(quic_donot_write_mid_packet_processing);
-
   // Indicates whether we should proactively validate peer address on a
   // PATH_CHALLENGE received.
   bool should_proactively_validate_peer_address_on_path_challenge_ = false;
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index 221fed8..6966630 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -12722,10 +12722,6 @@
           connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE,
                                    std::make_unique<TaggingEncrypter>(0x04));
           connection_.SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
-          if (!GetQuicReloadableFlag(quic_donot_write_mid_packet_processing)) {
-            // Retransmit rejected 0-RTT packets.
-            connection_.OnCanWrite();
-          }
           // Advance INITIAL ack delay to trigger initial ACK to be sent AFTER
           // the retransmission of rejected 0-RTT packets while the HANDSHAKE
           // packet is still in the coalescer, such that the INITIAL key gets
@@ -14994,23 +14990,13 @@
           InvokeWithoutArgs(&notifier_, &SimpleSessionNotifier::OnCanWrite));
   QuicIpAddress ip_address;
   ASSERT_TRUE(ip_address.FromString("127.0.52.223"));
-  if (GetQuicReloadableFlag(quic_donot_write_mid_packet_processing)) {
-    EXPECT_QUIC_BUG(
-        ProcessFramesPacketWithAddresses(frames, kSelfAddress,
-                                         QuicSocketAddress(ip_address, 1000),
-                                         ENCRYPTION_FORWARD_SECURE),
-        "Try to write mid packet processing");
-    EXPECT_EQ(1u, writer_->path_challenge_frames().size());
-    // Verify stream frame will not be retransmitted.
-    EXPECT_TRUE(writer_->stream_frames().empty());
-  } else {
-    ProcessFramesPacketWithAddresses(frames, kSelfAddress,
-                                     QuicSocketAddress(ip_address, 1000),
-                                     ENCRYPTION_FORWARD_SECURE);
-    // In prod, this would cause FAILED_TO_SERIALIZE_PACKET since the stream
-    // data has been freed, but simple_data_producer does not free data.
-    EXPECT_EQ(1u, writer_->stream_frames().size());
-  }
+  EXPECT_QUIC_BUG(ProcessFramesPacketWithAddresses(
+                      frames, kSelfAddress, QuicSocketAddress(ip_address, 1000),
+                      ENCRYPTION_FORWARD_SECURE),
+                  "Try to write mid packet processing");
+  EXPECT_EQ(1u, writer_->path_challenge_frames().size());
+  // Verify stream frame will not be retransmitted.
+  EXPECT_TRUE(writer_->stream_frames().empty());
 }
 
 TEST_P(QuicConnectionTest, PtoSendStreamData) {
diff --git a/quic/core/quic_flags_list.h b/quic/core/quic_flags_list.h
index d375591..0aa0ccc 100644
--- a/quic/core/quic_flags_list.h
+++ b/quic/core/quic_flags_list.h
@@ -69,8 +69,6 @@
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_count_bytes_on_alternative_path_seperately, true)
 // If true, do not re-arm PTO while sending application data during handshake.
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_donot_rearm_pto_on_application_data_during_handshake, true)
-// If true, do not write stream data and control frames in the middle of packet processing. 
-QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_donot_write_mid_packet_processing, true)
 // If true, drop unsent PATH_RESPONSEs and rely on peer\'s retry.
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_drop_unsent_path_response, true)
 // If true, enable server retransmittable on wire PING.
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index 2cd3525..df32cc5 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -567,17 +567,14 @@
 }
 
 void QuicSession::OnCanWrite() {
-  if (connection_->donot_write_mid_packet_processing()) {
-    QUIC_RELOADABLE_FLAG_COUNT_N(quic_donot_write_mid_packet_processing, 1, 3);
-    if (connection_->framer().is_processing_packet()) {
-      // Do not write data in the middle of packet processing because rest
-      // frames in the packet may change the data to write. For example, lost
-      // data could be acknowledged. Also, connection is going to emit
-      // OnCanWrite signal post packet processing.
-      QUIC_BUG(session_write_mid_packet_processing)
-          << ENDPOINT << "Try to write mid packet processing.";
-      return;
-    }
+  if (connection_->framer().is_processing_packet()) {
+    // Do not write data in the middle of packet processing because rest
+    // frames in the packet may change the data to write. For example, lost
+    // data could be acknowledged. Also, connection is going to emit
+    // OnCanWrite signal post packet processing.
+    QUIC_BUG(session_write_mid_packet_processing)
+        << ENDPOINT << "Try to write mid packet processing.";
+    return;
   }
   if (!RetransmitLostData()) {
     // Cannot finish retransmitting lost data, connection is write blocked.
@@ -1297,8 +1294,7 @@
   // Or if this session is configured on TLS enabled QUIC versions,
   // attempt to retransmit 0-RTT data if there's any.
   // TODO(fayang): consider removing this OnCanWrite call.
-  if ((!connection_->donot_write_mid_packet_processing() ||
-       !connection_->framer().is_processing_packet()) &&
+  if (!connection_->framer().is_processing_packet() &&
       (connection_->version().AllowsLowFlowControlLimits() ||
        version().UsesTls())) {
     QUIC_CODE_COUNT(quic_session_on_can_write_on_config_negotiated);
@@ -1605,8 +1601,7 @@
         // Retransmit old 0-RTT data (if any) with the new 0-RTT keys, since
         // they can't be decrypted by the server.
         connection_->MarkZeroRttPacketsForRetransmission(0);
-        if (!connection_->donot_write_mid_packet_processing() ||
-            !connection_->framer().is_processing_packet()) {
+        if (!connection_->framer().is_processing_packet()) {
           // TODO(fayang): consider removing this OnCanWrite call.
           // Given any streams blocked by encryption a chance to write.
           QUIC_CODE_COUNT(
diff --git a/quic/test_tools/simple_session_notifier.cc b/quic/test_tools/simple_session_notifier.cc
index 62ab05a..a1383b0 100644
--- a/quic/test_tools/simple_session_notifier.cc
+++ b/quic/test_tools/simple_session_notifier.cc
@@ -162,16 +162,14 @@
 }
 
 void SimpleSessionNotifier::OnCanWrite() {
-  if (connection_->donot_write_mid_packet_processing()) {
-    if (connection_->framer().is_processing_packet()) {
-      // Do not write data in the middle of packet processing because rest
-      // frames in the packet may change the data to write. For example, lost
-      // data could be acknowledged. Also, connection is going to emit
-      // OnCanWrite signal post packet processing.
-      QUIC_BUG(simple_notifier_write_mid_packet_processing)
-          << "Try to write mid packet processing.";
-      return;
-    }
+  if (connection_->framer().is_processing_packet()) {
+    // Do not write data in the middle of packet processing because rest
+    // frames in the packet may change the data to write. For example, lost
+    // data could be acknowledged. Also, connection is going to emit
+    // OnCanWrite signal post packet processing.
+    QUIC_BUG(simple_notifier_write_mid_packet_processing)
+        << "Try to write mid packet processing.";
+    return;
   }
   if (!RetransmitLostCryptoData() || !RetransmitLostControlFrames() ||
       !RetransmitLostStreamData()) {