Refactor QuicSession to allow subclasses to do their own thing on pending streams.

gfe-relnote: code refactor and v99 only. Not used in production.
PiperOrigin-RevId: 248015584
Change-Id: Ie0ac855070b304bd90a8e68392cff3cf4c5ac52a
diff --git a/quic/core/quic_session_test.cc b/quic/core/quic_session_test.cc
index a441dc4..8f418c0 100644
--- a/quic/core/quic_session_test.cc
+++ b/quic/core/quic_session_test.cc
@@ -138,7 +138,7 @@
                     CurrentSupportedVersions()),
         crypto_stream_(this),
         writev_consumes_all_data_(false),
-        should_buffer_incoming_streams_(false),
+        uses_pending_streams_(false),
         num_incoming_streams_created_(0) {
     Initialize();
     this->connection()->SetEncrypter(
@@ -209,6 +209,17 @@
     return stream;
   }
 
+  // QuicSession doesn't do anything in this method. So it's overridden here to
+  // test that the session handles pending streams correctly in terms of
+  // receiving stream frames.
+  void ProcessPendingStream(PendingStream* pending) override {
+    struct iovec iov;
+    if (pending->sequencer()->GetReadableRegion(&iov)) {
+      // Create TestStream once the first byte is received.
+      CreateIncomingStream(std::move(*pending));
+    }
+  }
+
   bool IsClosedStream(QuicStreamId id) {
     return QuicSession::IsClosedStream(id);
   }
@@ -279,12 +290,10 @@
     return WritevData(stream, stream->id(), bytes, 0, FIN);
   }
 
-  bool ShouldBufferIncomingStream(QuicStreamId id) const override {
-    return should_buffer_incoming_streams_;
-  }
+  bool UsesPendingStreams() const override { return uses_pending_streams_; }
 
-  void set_should_buffer_incoming_streams(bool should_buffer_incoming_streams) {
-    should_buffer_incoming_streams_ = should_buffer_incoming_streams;
+  void set_uses_pending_streams(bool uses_pending_streams) {
+    uses_pending_streams_ = uses_pending_streams;
   }
 
   int num_incoming_streams_created() const {
@@ -299,7 +308,7 @@
   StrictMock<TestCryptoStream> crypto_stream_;
 
   bool writev_consumes_all_data_;
-  bool should_buffer_incoming_streams_;
+  bool uses_pending_streams_;
   QuicFrame save_frame_;
   int num_incoming_streams_created_;
 };
@@ -1575,7 +1584,7 @@
 }
 
 TEST_P(QuicSessionTestServer, NoPendingStreams) {
-  session_.set_should_buffer_incoming_streams(false);
+  session_.set_uses_pending_streams(false);
 
   QuicStreamId stream_id = QuicUtils::GetFirstUnidirectionalStreamId(
       transport_version(), Perspective::IS_CLIENT);
@@ -1592,7 +1601,7 @@
   if (connection_->transport_version() != QUIC_VERSION_99) {
     return;
   }
-  session_.set_should_buffer_incoming_streams(true);
+  session_.set_uses_pending_streams(true);
 
   QuicStreamId stream_id = QuicUtils::GetFirstUnidirectionalStreamId(
       transport_version(), Perspective::IS_CLIENT);
@@ -1609,7 +1618,7 @@
   if (connection_->transport_version() != QUIC_VERSION_99) {
     return;
   }
-  session_.set_should_buffer_incoming_streams(true);
+  session_.set_uses_pending_streams(true);
 
   QuicStreamId stream_id = QuicUtils::GetFirstUnidirectionalStreamId(
       transport_version(), Perspective::IS_CLIENT);