Move handling of STOP_SENDING frame from QuicSession to QuicStream.

Refactor only. not protected.

PiperOrigin-RevId: 321656082
Change-Id: I430fc25ab69436c817d95c5ef6626e69ddb80dda
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index 0a9f872..5bfc517 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -256,22 +256,7 @@
     return;
   }
 
-  if (!stream->OnStopSending(frame.application_error_code)) {
-    return;
-  }
-
-  // TODO(renjietang): Consider moving those code into the stream.
-  if (connection()->connected()) {
-    MaybeSendRstStreamFrame(
-        stream->id(),
-        static_cast<quic::QuicRstStreamErrorCode>(frame.application_error_code),
-        stream->stream_bytes_written());
-    connection_->OnStreamReset(stream->id(),
-                               static_cast<quic::QuicRstStreamErrorCode>(
-                                   frame.application_error_code));
-  }
-  stream->set_rst_sent(true);
-  stream->CloseWriteSide();
+  stream->OnStopSending(frame.application_error_code);
 }
 
 void QuicSession::OnPacketDecrypted(EncryptionLevel level) {
@@ -759,11 +744,14 @@
 
 void QuicSession::SendRstStream(QuicStreamId id,
                                 QuicRstStreamErrorCode error,
-                                QuicStreamOffset bytes_written) {
+                                QuicStreamOffset bytes_written,
+                                bool send_rst_only) {
   if (connection()->connected()) {
     QuicConnection::ScopedPacketFlusher flusher(connection());
     MaybeSendRstStreamFrame(id, error, bytes_written);
-    MaybeSendStopSendingFrame(id, error);
+    if (!send_rst_only) {
+      MaybeSendStopSendingFrame(id, error);
+    }
 
     connection_->OnStreamReset(id, error);
   }
@@ -783,7 +771,7 @@
     return;
   }
 
-  SendRstStream(id, error, 0);
+  SendRstStream(id, error, 0, /*send_rst_only = */ false);
 }
 
 void QuicSession::MaybeSendRstStreamFrame(QuicStreamId id,