gfe-relnote: In QUIC, notify frame acked when discarding initial key. Protected by gfe2_reloadable_flag_quic_neuter_unencrypted_control_frames.

This is enabled when using TLS handshake.

PiperOrigin-RevId: 293194952
Change-Id: I5850ee7b56351b494465ba639c481996239ff3df
diff --git a/quic/core/quic_sent_packet_manager_test.cc b/quic/core/quic_sent_packet_manager_test.cc
index c677afa..6b34482 100644
--- a/quic/core/quic_sent_packet_manager_test.cc
+++ b/quic/core/quic_sent_packet_manager_test.cc
@@ -3410,6 +3410,23 @@
             manager_.GetRetransmissionTime());
 }
 
+// Regresstion test for b/148841700.
+TEST_F(QuicSentPacketManagerTest, NeuterUnencryptedPackets) {
+  SendCryptoPacket(1);
+  SendPingPacket(2, ENCRYPTION_INITIAL);
+  // Crypto data has been discarded but ping does not.
+  if (GetQuicReloadableFlag(quic_neuter_unencrypted_control_frames)) {
+    EXPECT_CALL(notifier_, OnFrameAcked(_, _, _))
+        .Times(2)
+        .WillOnce(Return(false))
+        .WillOnce(Return(true));
+  } else {
+    EXPECT_CALL(notifier_, OnFrameAcked(_, _, _)).Times(0);
+  }
+  EXPECT_CALL(notifier_, IsFrameOutstanding(_)).WillRepeatedly(Return(false));
+  manager_.NeuterUnencryptedPackets();
+}
+
 }  // namespace
 }  // namespace test
 }  // namespace quic
diff --git a/quic/core/quic_unacked_packet_map.cc b/quic/core/quic_unacked_packet_map.cc
index ef08535..c80593f 100644
--- a/quic/core/quic_unacked_packet_map.cc
+++ b/quic/core/quic_unacked_packet_map.cc
@@ -218,6 +218,16 @@
       // it from in flight.
       RemoveFromInFlight(packet_number);
       it->state = NEUTERED;
+      if (GetQuicReloadableFlag(quic_neuter_unencrypted_control_frames) ||
+          supports_multiple_packet_number_spaces_) {
+        if (GetQuicReloadableFlag(quic_neuter_unencrypted_control_frames)) {
+          QUIC_RELOADABLE_FLAG_COUNT(quic_neuter_unencrypted_control_frames);
+        }
+        // Notify session that the data has been delivered (but do not notify
+        // send algorithm).
+        // TODO(b/148868195): use NotifyFramesNeutered.
+        NotifyFramesAcked(*it, QuicTime::Delta::Zero(), QuicTime::Zero());
+      }
       DCHECK(!HasRetransmittableFrames(*it));
     }
   }
@@ -236,6 +246,7 @@
       // Notify session that the data has been delivered (but do not notify
       // send algorithm).
       it->state = NEUTERED;
+      // TODO(b/148868195): use NotifyFramesNeutered.
       NotifyFramesAcked(*it, QuicTime::Delta::Zero(), QuicTime::Zero());
     }
   }