Fix a bug in `QuicSession::GetFlowControlSendWindowSize` when the input stream id is a qpack stream id.

Protected by FLAGS_quic_opport_bundle_qpack_decoder_data5 (Replaces v4 flag).

PiperOrigin-RevId: 630643286
diff --git a/quiche/common/quiche_feature_flags_list.h b/quiche/common/quiche_feature_flags_list.h
index 126b3a0..611f308 100755
--- a/quiche/common/quiche_feature_flags_list.h
+++ b/quiche/common/quiche_feature_flags_list.h
@@ -48,7 +48,7 @@
 QUICHE_FLAG(bool, quiche_reloadable_flag_quic_testonly_default_false, false, "A testonly reloadable flag that will always default to false.")
 QUICHE_FLAG(bool, quiche_reloadable_flag_quic_testonly_default_true, true, "A testonly reloadable flag that will always default to true.")
 QUICHE_FLAG(bool, quiche_reloadable_flag_quic_use_received_client_addresses_cache, true, "If true, use a LRU cache to record client addresses of packets received on server's original address.")
-QUICHE_FLAG(bool, quiche_restart_flag_quic_opport_bundle_qpack_decoder_data4, false, "If true, bundle qpack decoder data with other frames opportunistically.")
+QUICHE_FLAG(bool, quiche_restart_flag_quic_opport_bundle_qpack_decoder_data5, false, "If true, bundle qpack decoder data with other frames opportunistically.")
 QUICHE_FLAG(bool, quiche_restart_flag_quic_support_ect1, false, "When true, allows sending of QUIC packets marked ECT(1). A different flag (TBD) will actually utilize this capability to send ECT(1).")
 QUICHE_FLAG(bool, quiche_restart_flag_quic_support_release_time_for_gso, false, "If true, QuicGsoBatchWriter will support release time if it is available and the process has the permission to do so.")
 QUICHE_FLAG(bool, quiche_restart_flag_quic_testonly_default_false, false, "A testonly restart flag that will always default to false.")
diff --git a/quiche/quic/core/http/end_to_end_test.cc b/quiche/quic/core/http/end_to_end_test.cc
index 710890b..09b7645 100644
--- a/quiche/quic/core/http/end_to_end_test.cc
+++ b/quiche/quic/core/http/end_to_end_test.cc
@@ -2845,7 +2845,7 @@
       client_connection->GetStats().packets_sent;
 
   if (version_.UsesHttp3()) {
-    if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+    if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
       // QPACK decoder instructions and RESET_STREAM and STOP_SENDING frames are
       // sent in a single packet.
       EXPECT_EQ(packets_sent_before + 1, packets_sent_now);
@@ -3028,7 +3028,7 @@
     return;
   }
   override_client_connection_id_length_ = kQuicDefaultConnectionIdLength;
-  SetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4, false);
+  SetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5, false);
   ASSERT_TRUE(Initialize());
   SendSynchronousFooRequestAndCheckResponse();
 
diff --git a/quiche/quic/core/http/quic_spdy_session.cc b/quiche/quic/core/http/quic_spdy_session.cc
index 752f83f..7f7f832 100644
--- a/quiche/quic/core/http/quic_spdy_session.cc
+++ b/quiche/quic/core/http/quic_spdy_session.cc
@@ -866,7 +866,7 @@
 }
 
 bool QuicSpdySession::CheckStreamWriteBlocked(QuicStream* stream) const {
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4) &&
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5) &&
       qpack_decoder_send_stream_ != nullptr &&
       stream->id() == qpack_decoder_send_stream_->id()) {
     // Decoder data is always bundled opportunistically.
diff --git a/quiche/quic/core/http/quic_spdy_session_test.cc b/quiche/quic/core/http/quic_spdy_session_test.cc
index fc9ed5c..9903e79 100644
--- a/quiche/quic/core/http/quic_spdy_session_test.cc
+++ b/quiche/quic/core/http/quic_spdy_session_test.cc
@@ -1361,7 +1361,7 @@
   // In HTTP/3, Qpack stream will send data on stream reset and cause packet to
   // be flushed.
   if (VersionUsesHttp3(transport_version()) &&
-      !GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+      !GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(*writer_, WritePacket(_, _, _, _, _, _))
         .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
   }
@@ -1606,7 +1606,7 @@
     // the STOP_SENDING, so set up the EXPECT there.
     EXPECT_CALL(*connection_, OnStreamReset(stream->id(), _));
     EXPECT_CALL(*connection_, SendControlFrame(_));
-  } else if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  } else if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(*writer_, WritePacket(_, _, _, _, _, _))
         .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
   }
diff --git a/quiche/quic/core/http/quic_spdy_stream_test.cc b/quiche/quic/core/http/quic_spdy_stream_test.cc
index 0eb0837..d16217f 100644
--- a/quiche/quic/core/http/quic_spdy_stream_test.cc
+++ b/quiche/quic/core/http/quic_spdy_stream_test.cc
@@ -584,7 +584,7 @@
           stream_->id(),
           QuicResetStreamError::FromInternal(QUIC_HEADERS_TOO_LARGE), 0));
 
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     auto qpack_decoder_stream =
         QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get());
     // Stream type and stream cancellation.
@@ -2256,7 +2256,7 @@
   std::string headers = HeadersFrame(encoded_headers);
   EXPECT_CALL(debug_visitor,
               OnHeadersFrameReceived(stream_->id(), encoded_headers.length()));
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     // Decoder stream type.
     EXPECT_CALL(*session_,
                 WritevData(decoder_send_stream->id(), /* write_length = */ 1,
@@ -2294,7 +2294,7 @@
   EXPECT_CALL(debug_visitor,
               OnHeadersFrameReceived(stream_->id(), encoded_trailers.length()));
   // Header acknowledgement.
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(*session_,
                 WritevData(decoder_send_stream->id(), _, _, _, _, _));
   }
@@ -2337,7 +2337,7 @@
   auto decoder_send_stream =
       QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get());
 
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     // Decoder stream type.
     EXPECT_CALL(*session_,
                 WritevData(decoder_send_stream->id(), /* write_length = */ 1,
@@ -2377,7 +2377,7 @@
   // Decoding is blocked because dynamic table entry has not been received yet.
   EXPECT_FALSE(stream_->trailers_decompressed());
 
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     // Header acknowledgement.
     EXPECT_CALL(*session_,
                 WritevData(decoder_send_stream->id(), _, _, _, _, _));
@@ -2478,7 +2478,7 @@
   auto decoder_send_stream =
       QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get());
 
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     // Decoder stream type.
     EXPECT_CALL(*session_,
                 WritevData(decoder_send_stream->id(), /* write_length = */ 1,
@@ -2552,7 +2552,7 @@
   // Decoding is blocked because dynamic table entry has not been received yet.
   EXPECT_FALSE(stream_->headers_decompressed());
 
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     // Decoder stream type and stream cancellation instruction.
     auto decoder_send_stream =
         QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get());
@@ -2603,7 +2603,7 @@
   // Decoding is blocked because dynamic table entry has not been received yet.
   EXPECT_FALSE(stream_->headers_decompressed());
 
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     // Decoder stream type and stream cancellation instruction.
     auto decoder_send_stream =
         QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get());
@@ -2967,7 +2967,7 @@
       .WillOnce(InvokeWithoutArgs([this]() {
         auto* qpack_decoder_stream =
             QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get());
-        if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4) &&
+        if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5) &&
             GetQuicReloadableFlag(
                 quic_stop_reading_also_stops_header_decompression)) {
           EXPECT_CALL(*session_,
@@ -3027,7 +3027,7 @@
       .WillOnce(InvokeWithoutArgs([this]() {
         auto* qpack_decoder_stream =
             QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get());
-        if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4) &&
+        if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5) &&
             GetQuicReloadableFlag(
                 quic_stop_reading_also_stops_header_decompression)) {
           EXPECT_CALL(*session_,
@@ -3088,7 +3088,7 @@
       .WillOnce(InvokeWithoutArgs([this]() {
         auto* qpack_decoder_stream =
             QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get());
-        if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4) &&
+        if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5) &&
             GetQuicReloadableFlag(
                 quic_stop_reading_also_stops_header_decompression)) {
           EXPECT_CALL(*session_,
@@ -3150,7 +3150,7 @@
 
   auto qpack_decoder_stream =
       QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get());
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     // Stream type.
     EXPECT_CALL(*session_,
                 WritevData(qpack_decoder_stream->id(), /* write_length = */ 1,
@@ -3183,7 +3183,7 @@
 
   auto qpack_decoder_stream =
       QuicSpdySessionPeer::GetQpackDecoderSendStream(session_.get());
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     // Stream type.
     EXPECT_CALL(*session_,
                 WritevData(qpack_decoder_stream->id(), /* write_length = */ 1,
@@ -3577,7 +3577,7 @@
   QuicStreamFrame frame(stream_->id(), /* fin = */ false, 0, data_frame);
   stream_->OnStreamFrame(frame);
 
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     // As a result of resetting the stream, stream type and stream cancellation
     // are sent on the QPACK decoder stream.
     auto qpack_decoder_stream =
diff --git a/quiche/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc b/quiche/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc
index 1a718a5..cd31cd5 100644
--- a/quiche/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc
+++ b/quiche/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc
@@ -191,7 +191,7 @@
 
   EXPECT_CALL(visitor_, OnHeadersDecoded(_, true));
   qpack_decoder_.OnInsertWithoutNameReference("foo", "bar");
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     qpack_decoder_.FlushDecoderStream();
   }
 }
@@ -218,7 +218,7 @@
   EXPECT_EQ(strlen("foo") + strlen("bar"),
             header_list.uncompressed_header_bytes());
   EXPECT_EQ(encoded_data.size(), header_list.compressed_header_bytes());
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     qpack_decoder_.FlushDecoderStream();
   }
 }
@@ -247,7 +247,7 @@
   accumulator_.EndHeaderBlock();
 
   EXPECT_THAT(header_list, ElementsAre(Pair("foo", "bar"), Pair("foo", "bar")));
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     qpack_decoder_.FlushDecoderStream();
   }
 }
diff --git a/quiche/quic/core/qpack/qpack_decoder.cc b/quiche/quic/core/qpack/qpack_decoder.cc
index 02c590d..b5b581d 100644
--- a/quiche/quic/core/qpack/qpack_decoder.cc
+++ b/quiche/quic/core/qpack/qpack_decoder.cc
@@ -31,7 +31,7 @@
 void QpackDecoder::OnStreamReset(QuicStreamId stream_id) {
   if (header_table_.maximum_dynamic_table_capacity() > 0) {
     decoder_stream_sender_.SendStreamCancellation(stream_id);
-    if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+    if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
       decoder_stream_sender_.Flush();
     }
   }
@@ -68,7 +68,7 @@
     known_received_count_ = header_table_.inserted_entry_count();
   }
 
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     decoder_stream_sender_.Flush();
   }
 }
diff --git a/quiche/quic/core/qpack/qpack_decoder_stream_sender.cc b/quiche/quic/core/qpack/qpack_decoder_stream_sender.cc
index 98245c4..7ebc9a5 100644
--- a/quiche/quic/core/qpack/qpack_decoder_stream_sender.cc
+++ b/quiche/quic/core/qpack/qpack_decoder_stream_sender.cc
@@ -42,8 +42,8 @@
   if (buffer_.empty() || delegate_ == nullptr) {
     return;
   }
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
-    QUIC_RESTART_FLAG_COUNT_N(quic_opport_bundle_qpack_decoder_data4, 3, 4);
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
+    QUIC_RESTART_FLAG_COUNT_N(quic_opport_bundle_qpack_decoder_data5, 3, 4);
     // Swap buffer_ before calling WriteStreamData, which might result in a
     // reentrant call to `Flush()`.
     std::string copy;
diff --git a/quiche/quic/core/qpack/qpack_decoder_test.cc b/quiche/quic/core/qpack/qpack_decoder_test.cc
index 78fadd2..321445b 100644
--- a/quiche/quic/core/qpack/qpack_decoder_test.cc
+++ b/quiche/quic/core/qpack/qpack_decoder_test.cc
@@ -420,13 +420,13 @@
       .InSequence(s);
   EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("ZZZ"))).InSequence(s);
   EXPECT_CALL(handler_, OnHeaderDecoded(Eq(":method"), Eq("ZZ"))).InSequence(s);
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(decoder_stream_sender_delegate_,
                 WriteStreamData(Eq(kHeaderAcknowledgement)))
         .InSequence(s);
   }
   EXPECT_CALL(handler_, OnDecodingCompleted()).InSequence(s);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(decoder_stream_sender_delegate_,
                 WriteStreamData(Eq(kHeaderAcknowledgement)))
         .InSequence(s);
@@ -443,7 +443,7 @@
                    // with value "ZZ".
       &input));
   DecodeHeaderBlock(input);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     FlushDecoderStream();
   }
 
@@ -453,13 +453,13 @@
       .InSequence(s);
   EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("ZZZ"))).InSequence(s);
   EXPECT_CALL(handler_, OnHeaderDecoded(Eq(":method"), Eq("ZZ"))).InSequence(s);
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(decoder_stream_sender_delegate_,
                 WriteStreamData(Eq(kHeaderAcknowledgement)))
         .InSequence(s);
   }
   EXPECT_CALL(handler_, OnDecodingCompleted()).InSequence(s);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(decoder_stream_sender_delegate_,
                 WriteStreamData(Eq(kHeaderAcknowledgement)))
         .InSequence(s);
@@ -476,7 +476,7 @@
                    // with value "ZZ".
       &input));
   DecodeHeaderBlock(input);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     FlushDecoderStream();
   }
 
@@ -486,13 +486,13 @@
       .InSequence(s);
   EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("ZZZ"))).InSequence(s);
   EXPECT_CALL(handler_, OnHeaderDecoded(Eq(":method"), Eq("ZZ"))).InSequence(s);
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(decoder_stream_sender_delegate_,
                 WriteStreamData(Eq(kHeaderAcknowledgement)))
         .InSequence(s);
   }
   EXPECT_CALL(handler_, OnDecodingCompleted()).InSequence(s);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(decoder_stream_sender_delegate_,
                 WriteStreamData(Eq(kHeaderAcknowledgement)))
         .InSequence(s);
@@ -509,7 +509,7 @@
                    // with value "ZZ".
       &input));
   DecodeHeaderBlock(input);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     FlushDecoderStream();
   }
 }
@@ -550,7 +550,7 @@
       "80",   // Dynamic table entry with relative index 0, absolute index 0.
       &input));
   DecodeHeaderBlock(input);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     FlushDecoderStream();
   }
 }
@@ -837,7 +837,7 @@
       "80",   // Emit dynamic table entry with relative index 0.
       &input));
   DecodeHeaderBlock(input);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     FlushDecoderStream();
   }
 }
@@ -1032,7 +1032,7 @@
   // Add literal entry with name "foo" and value "bar".
   ASSERT_TRUE(absl::HexStringToBytes("6294e703626172", &input));
   DecodeEncoderStreamData(input);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     FlushDecoderStream();
   }
 }
@@ -1079,7 +1079,7 @@
   EXPECT_CALL(decoder_stream_sender_delegate_,
               WriteStreamData(Eq(kHeaderAcknowledgement)));
   EndDecoding();
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     FlushDecoderStream();
   }
 }
@@ -1147,7 +1147,7 @@
   // Insert Count is now 6, reaching Required Insert Count of the header block.
   ASSERT_TRUE(absl::HexStringToBytes("6294e70362617a", &input));
   DecodeEncoderStreamData(input);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     FlushDecoderStream();
   }
 }
@@ -1199,7 +1199,7 @@
       "80",   // Dynamic table entry with relative index 0, absolute index 0.
       &input));
   DecodeHeaderBlock(input);
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     FlushDecoderStream();
   }
 }
diff --git a/quiche/quic/core/qpack/qpack_send_stream_test.cc b/quiche/quic/core/qpack/qpack_send_stream_test.cc
index 4f0cc2a..acde4ef 100644
--- a/quiche/quic/core/qpack/qpack_send_stream_test.cc
+++ b/quiche/quic/core/qpack/qpack_send_stream_test.cc
@@ -128,6 +128,12 @@
   qpack_send_stream_->OnStreamFrame(frame);
 }
 
+TEST_P(QpackSendStreamTest, GetSendWindowSizeFromSession) {
+  SetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5, true);
+  EXPECT_NE(session_.GetFlowControlSendWindowSize(qpack_send_stream_->id()),
+            std::numeric_limits<QuicByteCount>::max());
+}
+
 }  // namespace
 }  // namespace test
 }  // namespace quic
diff --git a/quiche/quic/core/quic_connection.cc b/quiche/quic/core/quic_connection.cc
index ca51deb..a948746 100644
--- a/quiche/quic/core/quic_connection.cc
+++ b/quiche/quic/core/quic_connection.cc
@@ -3048,8 +3048,8 @@
 
 void QuicConnection::MaybeBundleOpportunistically(
     TransmissionType transmission_type) {
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
-    QUIC_RESTART_FLAG_COUNT_N(quic_opport_bundle_qpack_decoder_data4, 1, 4);
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
+    QUIC_RESTART_FLAG_COUNT_N(quic_opport_bundle_qpack_decoder_data5, 1, 4);
 
     const bool should_bundle_ack_frequency =
         !ack_frequency_sent_ && sent_packet_manager_.CanSendAckFrequency() &&
@@ -5703,8 +5703,8 @@
       uber_received_packet_manager_.GetEarliestAckTimeout();
   QUIC_BUG_IF(quic_bug_12714_32, !earliest_ack_timeout.IsInitialized());
   MaybeBundleCryptoDataWithAcks();
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
-    QUIC_RESTART_FLAG_COUNT_N(quic_opport_bundle_qpack_decoder_data4, 2, 4);
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
+    QUIC_RESTART_FLAG_COUNT_N(quic_opport_bundle_qpack_decoder_data5, 2, 4);
     visitor_->MaybeBundleOpportunistically();
   }
   earliest_ack_timeout = uber_received_packet_manager_.GetEarliestAckTimeout();
diff --git a/quiche/quic/core/quic_connection_test.cc b/quiche/quic/core/quic_connection_test.cc
index b199c6d..7f3208a 100644
--- a/quiche/quic/core/quic_connection_test.cc
+++ b/quiche/quic/core/quic_connection_test.cc
@@ -700,7 +700,7 @@
     EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber());
     EXPECT_CALL(visitor_, OnPacketReceived(_, _, _)).Times(AnyNumber());
     EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)).Times(AnyNumber());
-    if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+    if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
       EXPECT_CALL(visitor_, MaybeBundleOpportunistically()).Times(AnyNumber());
       EXPECT_CALL(visitor_, GetFlowControlSendWindowSize(_)).Times(AnyNumber());
     }
diff --git a/quiche/quic/core/quic_flags_list.h b/quiche/quic/core/quic_flags_list.h
index ed4435f..0f67d88 100644
--- a/quiche/quic/core/quic_flags_list.h
+++ b/quiche/quic/core/quic_flags_list.h
@@ -38,7 +38,7 @@
 // If true, an endpoint does not detect path degrading or blackholing until handshake gets confirmed.
 QUIC_FLAG(quic_reloadable_flag_quic_no_path_degrading_before_handshake_confirmed, true)
 // If true, bundle qpack decoder data with other frames opportunistically.
-QUIC_FLAG(quic_restart_flag_quic_opport_bundle_qpack_decoder_data4, false)
+QUIC_FLAG(quic_restart_flag_quic_opport_bundle_qpack_decoder_data5, false)
 // If true, default-enable 5RTO blachole detection.
 QUIC_FLAG(quic_reloadable_flag_quic_default_enable_5rto_blackhole_detection2, true)
 // If true, disable QUIC version Q046.
diff --git a/quiche/quic/core/quic_packet_creator.cc b/quiche/quic/core/quic_packet_creator.cc
index c54d76d..021e637 100644
--- a/quiche/quic/core/quic_packet_creator.cc
+++ b/quiche/quic/core/quic_packet_creator.cc
@@ -1313,7 +1313,7 @@
 }
 
 void QuicPacketCreator::MaybeBundleOpportunistically() {
-  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (!GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     delegate_->MaybeBundleOpportunistically(next_transmission_type_);
     return;
   }
@@ -1337,7 +1337,7 @@
   const TransmissionType next_transmission_type = next_transmission_type_;
   MaybeBundleOpportunistically();
   // TODO(wub): Remove this QUIC_BUG when deprecating
-  // quic_opport_bundle_qpack_decoder_data4.
+  // quic_opport_bundle_qpack_decoder_data5.
   QUIC_BUG_IF(quic_packet_creator_change_transmission_type,
               next_transmission_type != next_transmission_type_)
       << ENDPOINT
@@ -1353,11 +1353,11 @@
   // - And it's not handshake data. This is always true for ConsumeData because
   //   the function is not called for handshake data.
   const size_t original_write_length = write_length;
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4) &&
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5) &&
       next_transmission_type_ == NOT_RETRANSMISSION) {
     if (QuicByteCount send_window = delegate_->GetFlowControlSendWindowSize(id);
         write_length > send_window) {
-      QUIC_RESTART_FLAG_COUNT_N(quic_opport_bundle_qpack_decoder_data4, 4, 4);
+      QUIC_RESTART_FLAG_COUNT_N(quic_opport_bundle_qpack_decoder_data5, 4, 4);
       QUIC_DLOG(INFO) << ENDPOINT
                       << "After bundled data, reducing (old) write_length:"
                       << write_length << "to (new) send_window:" << send_window;
diff --git a/quiche/quic/core/quic_packet_creator_test.cc b/quiche/quic/core/quic_packet_creator_test.cc
index 472dc7f..6aabdce 100644
--- a/quiche/quic/core/quic_packet_creator_test.cc
+++ b/quiche/quic/core/quic_packet_creator_test.cc
@@ -2931,7 +2931,7 @@
   QuicStreamId stream_id = QuicUtils::GetFirstBidirectionalStreamId(
       framer_.transport_version(), Perspective::IS_CLIENT);
 
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(delegate_, GetFlowControlSendWindowSize(stream_id))
         .WillOnce(Return(data.length() - 1));
   } else {
@@ -2940,7 +2940,7 @@
 
   QuicConsumedData consumed = creator_.ConsumeData(stream_id, data, 0u, FIN);
 
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_EQ(consumed.bytes_consumed, data.length() - 1);
     EXPECT_FALSE(consumed.fin_consumed);
   } else {
@@ -2961,7 +2961,7 @@
   QuicStreamId stream_id = QuicUtils::GetFirstBidirectionalStreamId(
       framer_.transport_version(), Perspective::IS_CLIENT);
 
-  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data4)) {
+  if (GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5)) {
     EXPECT_CALL(delegate_, GetFlowControlSendWindowSize(stream_id))
         .WillOnce(Return(data.length()));
   } else {
diff --git a/quiche/quic/core/quic_session.cc b/quiche/quic/core/quic_session.cc
index f8c763d..d6cdc73 100644
--- a/quiche/quic/core/quic_session.cc
+++ b/quiche/quic/core/quic_session.cc
@@ -2486,13 +2486,14 @@
 }
 
 QuicByteCount QuicSession::GetFlowControlSendWindowSize(QuicStreamId id) {
-  QuicStream* stream = GetActiveStream(id);
-  if (stream == nullptr) {
+  QUICHE_DCHECK(GetQuicRestartFlag(quic_opport_bundle_qpack_decoder_data5));
+  auto it = stream_map_.find(id);
+  if (it == stream_map_.end()) {
     // No flow control for invalid or inactive stream ids. Returning uint64max
     // allows QuicPacketCreator to write as much data as possible.
     return std::numeric_limits<QuicByteCount>::max();
   }
-  return stream->CalculateSendWindowSize();
+  return it->second->CalculateSendWindowSize();
 }
 
 WriteStreamDataResult QuicSession::WriteStreamData(QuicStreamId id,