Add flag to QuicSession indicating that it has been configured

This CL adds a flag to QuicSession that indicates when the QuicSession has been
configured. This needed for follow-on work where IETF QUIC is limited as to the
frames that can be sent _until_ the transport config has been performed.

QuicSession test has been modified to A) artificially perform a configuration
and B) check at test termination that it has been configured.

gfe-relnote: N/A not significant. Other changes all to tests.
PiperOrigin-RevId: 264362154
Change-Id: I1467cd4ed4531c01950d3fb938637e8633de815e
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index 5486e64..fd3d489 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -89,7 +89,8 @@
       last_message_id_(0),
       closed_streams_clean_up_alarm_(nullptr),
       supported_versions_(supported_versions),
-      use_http2_priority_write_scheduler_(false) {
+      use_http2_priority_write_scheduler_(false),
+      is_configured_(false) {
   closed_streams_clean_up_alarm_ =
       QuicWrapUnique<QuicAlarm>(connection_->alarm_factory()->CreateAlarm(
           new ClosedStreamsCleanUpDelegate(this)));
@@ -1051,6 +1052,7 @@
     OnNewSessionFlowControlWindow(
         config_.ReceivedInitialSessionFlowControlWindowBytes());
   }
+  is_configured_ = true;
 }
 
 void QuicSession::AdjustInitialFlowControlWindows(size_t stream_window) {
diff --git a/quic/core/quic_session.h b/quic/core/quic_session.h
index 6ab56f9..8216bbd 100644
--- a/quic/core/quic_session.h
+++ b/quic/core/quic_session.h
@@ -431,6 +431,8 @@
     return use_http2_priority_write_scheduler_;
   }
 
+  bool is_configured() const { return is_configured_; }
+
  protected:
   using StreamMap = QuicSmallMap<QuicStreamId, std::unique_ptr<QuicStream>, 10>;
 
@@ -724,6 +726,10 @@
   // If true, write_blocked_streams_ uses HTTP2 (tree-style) priority write
   // scheduler.
   bool use_http2_priority_write_scheduler_;
+
+  // Initialized to false. Set to true when the session has been properly
+  // configured and is ready for general operation.
+  bool is_configured_;
 };
 
 }  // namespace quic
diff --git a/quic/core/quic_session_test.cc b/quic/core/quic_session_test.cc
index 9111ee4..3a6db56 100644
--- a/quic/core/quic_session_test.cc
+++ b/quic/core/quic_session_test.cc
@@ -153,7 +153,10 @@
         QuicMakeUnique<NullEncrypter>(connection->perspective()));
   }
 
-  ~TestSession() override { delete connection(); }
+  ~TestSession() override {
+    EXPECT_TRUE(is_configured());
+    delete connection();
+  }
 
   TestCryptoStream* GetMutableCryptoStream() override {
     return &crypto_stream_;
@@ -329,7 +332,13 @@
         kInitialStreamFlowControlWindowForTest);
     session_.config()->SetInitialSessionFlowControlWindowToSend(
         kInitialSessionFlowControlWindowForTest);
+
+    QuicConfigPeer::SetReceivedMaxIncomingBidirectionalStreams(
+        session_.config(), kDefaultMaxStreamsPerConnection);
+    QuicConfigPeer::SetReceivedMaxIncomingUnidirectionalStreams(
+        session_.config(), kDefaultMaxStreamsPerConnection);
     connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
+    session_.OnConfigNegotiated();
     TestCryptoStream* crypto_stream = session_.GetMutableCryptoStream();
     EXPECT_CALL(*crypto_stream, HasPendingRetransmission())
         .Times(testing::AnyNumber());
diff --git a/quic/core/quic_stream_id_manager.cc b/quic/core/quic_stream_id_manager.cc
index 8865a1d..ca6d441 100644
--- a/quic/core/quic_stream_id_manager.cc
+++ b/quic/core/quic_stream_id_manager.cc
@@ -221,7 +221,8 @@
   // TODO(fkastenholz): Should we close the connection?
   QUIC_BUG_IF(outgoing_stream_count_ >= outgoing_max_streams_)
       << "Attempt to allocate a new outgoing stream that would exceed the "
-         "limit";
+         "limit ("
+      << outgoing_max_streams_ << ")";
   QuicStreamId id = next_outgoing_stream_id_;
   next_outgoing_stream_id_ += QuicUtils::StreamIdDelta(transport_version());
   outgoing_stream_count_++;