In QUIC BBRv2, use inflight byte after congestion event to detect queuing during PROBE_UP.

Protected by quic_reloadable_flag_quic_bbr2_use_post_inflight_to_detect_queuing.

PiperOrigin-RevId: 332262071
Change-Id: Ib057f75556f9b3bfe9873d5a538b938d6d38ba03
diff --git a/quic/core/congestion_control/bbr2_probe_bw.cc b/quic/core/congestion_control/bbr2_probe_bw.cc
index 59e6303..8cf8b2e 100644
--- a/quic/core/congestion_control/bbr2_probe_bw.cc
+++ b/quic/core/congestion_control/bbr2_probe_bw.cc
@@ -436,10 +436,16 @@
     QuicByteCount queuing_threshold =
         (Params().probe_bw_probe_inflight_gain * bdp) +
         queuing_threshold_extra_bytes;
-    is_queuing = prior_in_flight >= queuing_threshold;
+    if (GetQuicReloadableFlag(quic_bbr2_use_post_inflight_to_detect_queuing)) {
+      is_queuing = congestion_event.bytes_in_flight >= queuing_threshold;
+    } else {
+      is_queuing = prior_in_flight >= queuing_threshold;
+    }
     QUIC_DVLOG(3) << sender_
                   << " Checking if building up a queue. prior_in_flight:"
-                  << prior_in_flight << ", threshold:" << queuing_threshold
+                  << prior_in_flight
+                  << ", post_in_flight:" << congestion_event.bytes_in_flight
+                  << ", threshold:" << queuing_threshold
                   << ", is_queuing:" << is_queuing
                   << ", max_bw:" << model_->MaxBandwidth()
                   << ", min_rtt:" << model_->MinRtt();
diff --git a/quic/core/congestion_control/bbr2_simulator_test.cc b/quic/core/congestion_control/bbr2_simulator_test.cc
index 2036eb1..1f5db20 100644
--- a/quic/core/congestion_control/bbr2_simulator_test.cc
+++ b/quic/core/congestion_control/bbr2_simulator_test.cc
@@ -661,10 +661,10 @@
   }
 
   // Now that in-flight is almost zero and the pacing gain is still above 1,
-  // send approximately 1.25 BDPs worth of data.  This should cause the
-  // PROBE_BW mode to enter low gain cycle(PROBE_DOWN), and exit it earlier than
-  // one min_rtt due to running out of data to send.
-  sender_endpoint_.AddBytesToTransfer(1.3 * params.BDP());
+  // send approximately 1.4 BDPs worth of data. This should cause the PROBE_BW
+  // mode to enter low gain cycle(PROBE_DOWN), and exit it earlier than one
+  // min_rtt due to running out of data to send.
+  sender_endpoint_.AddBytesToTransfer(1.4 * params.BDP());
   simulator_result = simulator_.RunUntilOrTimeout(
       [this]() {
         return sender_->ExportDebugState().probe_bw.phase ==