Use a QuicSession member to latch
gfe2_reloadable_flag_quic_eliminate_static_stream_map_2.

This prevents unexpected behavior from runtime flag flipping.

gfe-relnote: gfe2_reloadable_flag_quic_eliminate_static_stream_map_2 replaces
gfe2_reloadable_flag_quic_eliminate_static_stream_map for rollout purposes.
PiperOrigin-RevId: 246926123
Change-Id: I11103af393e7fa93ea5b2d3cd90f9fe423fbed96
diff --git a/quic/core/http/quic_spdy_client_session_base.cc b/quic/core/http/quic_spdy_client_session_base.cc
index 4aa3348..2db5b84 100644
--- a/quic/core/http/quic_spdy_client_session_base.cc
+++ b/quic/core/http/quic_spdy_client_session_base.cc
@@ -95,8 +95,7 @@
     // It's quite possible to receive headers after a stream has been reset.
     return;
   }
-  if (GetQuicReloadableFlag(quic_eliminate_static_stream_map) &&
-      stream->is_static()) {
+  if (eliminate_static_stream_map() && stream->is_static()) {
     connection()->CloseConnection(
         QUIC_INVALID_HEADERS_STREAM_DATA, "stream is static",
         ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
diff --git a/quic/core/http/quic_spdy_session.cc b/quic/core/http/quic_spdy_session.cc
index cc1eee7..de34250 100644
--- a/quic/core/http/quic_spdy_session.cc
+++ b/quic/core/http/quic_spdy_session.cc
@@ -355,12 +355,12 @@
   headers_stream_ = QuicMakeUnique<QuicHeadersStream>((this));
   DCHECK_EQ(QuicUtils::GetHeadersStreamId(connection()->transport_version()),
             headers_stream_->id());
-  if (!GetQuicReloadableFlag(quic_eliminate_static_stream_map)) {
+  if (!eliminate_static_stream_map()) {
     RegisterStaticStream(
         QuicUtils::GetHeadersStreamId(connection()->transport_version()),
         headers_stream_.get());
   } else {
-    QUIC_RELOADABLE_FLAG_COUNT_N(quic_eliminate_static_stream_map, 7, 15);
+    QUIC_RELOADABLE_FLAG_COUNT_N(quic_eliminate_static_stream_map_2, 7, 17);
     unowned_headers_stream_ = headers_stream_.get();
     RegisterStaticStreamNew(std::move(headers_stream_));
   }
@@ -444,9 +444,8 @@
     // It's quite possible to receive headers after a stream has been reset.
     return;
   }
-  if (GetQuicReloadableFlag(quic_eliminate_static_stream_map) &&
-      stream->is_static()) {
-    QUIC_RELOADABLE_FLAG_COUNT_N(quic_eliminate_static_stream_map, 8, 15);
+  if (eliminate_static_stream_map() && stream->is_static()) {
+    QUIC_RELOADABLE_FLAG_COUNT_N(quic_eliminate_static_stream_map_2, 8, 17);
     connection()->CloseConnection(
         QUIC_INVALID_HEADERS_STREAM_DATA, "stream is static",
         ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
@@ -709,13 +708,13 @@
 }
 
 bool QuicSpdySession::HasActiveRequestStreams() const {
-  if (!GetQuicReloadableFlag(quic_eliminate_static_stream_map)) {
+  if (!eliminate_static_stream_map()) {
     return !dynamic_streams().empty();
   }
   // In the case where session is destructed by calling
   // dynamic_streams().clear(), we will have incorrect accounting here.
   // TODO(renjietang): Modify destructors and make this a DCHECK.
-  QUIC_RELOADABLE_FLAG_COUNT_N(quic_eliminate_static_stream_map, 9, 15);
+  QUIC_RELOADABLE_FLAG_COUNT_N(quic_eliminate_static_stream_map_2, 9, 17);
   if (static_cast<size_t>(dynamic_streams().size()) >
       num_incoming_static_streams() + num_outgoing_static_streams()) {
     return dynamic_streams().size() - num_incoming_static_streams() -
diff --git a/quic/core/http/quic_spdy_session.h b/quic/core/http/quic_spdy_session.h
index 9248fa5..23e57c3 100644
--- a/quic/core/http/quic_spdy_session.h
+++ b/quic/core/http/quic_spdy_session.h
@@ -140,15 +140,13 @@
   QpackEncoder* qpack_encoder();
   QpackDecoder* qpack_decoder();
   QuicHeadersStream* headers_stream() {
-    return GetQuicReloadableFlag(quic_eliminate_static_stream_map)
-               ? unowned_headers_stream_
-               : headers_stream_.get();
+    return eliminate_static_stream_map() ? unowned_headers_stream_
+                                         : headers_stream_.get();
   }
 
   const QuicHeadersStream* headers_stream() const {
-    return GetQuicReloadableFlag(quic_eliminate_static_stream_map)
-               ? unowned_headers_stream_
-               : headers_stream_.get();
+    return eliminate_static_stream_map() ? unowned_headers_stream_
+                                         : headers_stream_.get();
   }
 
   bool server_push_enabled() const { return server_push_enabled_; }
diff --git a/quic/core/http/quic_spdy_session_test.cc b/quic/core/http/quic_spdy_session_test.cc
index 83ea72f..6724e69 100644
--- a/quic/core/http/quic_spdy_session_test.cc
+++ b/quic/core/http/quic_spdy_session_test.cc
@@ -923,7 +923,7 @@
   TestCryptoStream* crypto_stream = session_.GetMutableCryptoStream();
   EXPECT_CALL(*crypto_stream, OnCanWrite());
   TestHeadersStream* headers_stream;
-  if (!GetQuicReloadableFlag(quic_eliminate_static_stream_map)) {
+  if (!GetQuicReloadableFlag(quic_eliminate_static_stream_map_2)) {
     QuicSpdySessionPeer::SetHeadersStream(&session_, nullptr);
     headers_stream = new TestHeadersStream(&session_);
     QuicSpdySessionPeer::SetHeadersStream(&session_, headers_stream);
@@ -1643,7 +1643,7 @@
 
 TEST_P(QuicSpdySessionTestClient, WritePriority) {
   TestHeadersStream* headers_stream;
-  if (!GetQuicReloadableFlag(quic_eliminate_static_stream_map)) {
+  if (!GetQuicReloadableFlag(quic_eliminate_static_stream_map_2)) {
     QuicSpdySessionPeer::SetHeadersStream(&session_, nullptr);
     headers_stream = new TestHeadersStream(&session_);
     QuicSpdySessionPeer::SetHeadersStream(&session_, headers_stream);