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.h b/quic/core/quic_session.h
index e0f2458..f16477c 100644
--- a/quic/core/quic_session.h
+++ b/quic/core/quic_session.h
@@ -483,11 +483,11 @@
   virtual void OnFinalByteOffsetReceived(QuicStreamId id,
                                          QuicStreamOffset final_byte_offset);
 
-  // Returns true if incoming streams should be buffered until the first
-  // byte of the stream arrives.
-  virtual bool ShouldBufferIncomingStream(QuicStreamId id) const {
-    return false;
-  }
+  // Returns true if incoming unidirectional streams should be buffered until
+  // the first byte of the stream arrives.
+  // If a subclass returns true here, it should make sure to implement
+  // ProcessPendingStream().
+  virtual bool UsesPendingStreams() const { return false; }
 
   // Register (|id|, |stream|) with the static stream map. Override previous
   // registrations with the same id.
@@ -573,11 +573,11 @@
     };
   };
 
-  StreamHandler GetOrCreateStreamImpl(QuicStreamId stream_id, bool may_buffer);
+  StreamHandler GetOrCreateStreamImpl(QuicStreamId stream_id);
 
   // Processes the stream type information of |pending| depending on
-  // different kinds of sessions's own rules.
-  virtual void ProcessPendingStreamType(PendingStream* pending) {}
+  // different kinds of sessions' own rules.
+  virtual void ProcessPendingStream(PendingStream* pending) {}
 
   bool eliminate_static_stream_map() const {
     return eliminate_static_stream_map_;
@@ -613,8 +613,9 @@
   // closed.
   QuicStream* GetStream(QuicStreamId id) const;
 
-  StreamHandler GetOrCreateDynamicStreamImpl(QuicStreamId stream_id,
-                                             bool may_buffer);
+  StreamHandler GetOrCreateDynamicStreamImpl(QuicStreamId stream_id);
+
+  PendingStream* GetOrCreatePendingStream(QuicStreamId stream_id);
 
   // Let streams and control frame managers retransmit lost data, returns true
   // if all lost data is retransmitted. Returns false otherwise.
@@ -623,6 +624,14 @@
   // Closes the pending stream |stream_id| before it has been created.
   void ClosePendingStream(QuicStreamId stream_id);
 
+  // Creates or gets pending stream, feeds it with |frame|, and processes the
+  // pending stream.
+  void PendingStreamOnStreamFrame(const QuicStreamFrame& frame);
+
+  // Creates or gets pending strea, feed it with |frame|, and closes the pending
+  // stream.
+  void PendingStreamOnRstStream(const QuicRstStreamFrame& frame);
+
   // Keep track of highest received byte offset of locally closed streams, while
   // waiting for a definitive final highest offset from the peer.
   std::map<QuicStreamId, QuicStreamOffset>