Make QuicSession::ResetStream() smarter.
If the stream reseted doesn't exist, we always send out 0 as the bytes written. And if it doesn, we always send what the stream has written. So we don't need the explicit parameter for bytes_written.
No behavior change. not protected.
PiperOrigin-RevId: 319211675
Change-Id: I6c96d94e2d0ec1eca0c86a4740a7384aa15c8529
diff --git a/quic/core/http/end_to_end_test.cc b/quic/core/http/end_to_end_test.cc
index 005e463..f333264 100644
--- a/quic/core/http/end_to_end_test.cc
+++ b/quic/core/http/end_to_end_test.cc
@@ -1944,7 +1944,7 @@
// Transmit the cancel, and ensure the connection is torn down properly.
SetPacketLossPercentage(0);
QuicStreamId stream_id = GetNthClientInitiatedBidirectionalId(0);
- session->ResetStream(stream_id, QUIC_STREAM_CANCELLED, 0);
+ session->ResetStream(stream_id, QUIC_STREAM_CANCELLED);
// WaitForEvents waits 50ms and returns true if there are outstanding
// requests.
diff --git a/quic/core/http/quic_client_promised_info_test.cc b/quic/core/http/quic_client_promised_info_test.cc
index 0836f9a..e1b00c8 100644
--- a/quic/core/http/quic_client_promised_info_test.cc
+++ b/quic/core/http/quic_client_promised_info_test.cc
@@ -328,7 +328,7 @@
EXPECT_CALL(*connection_, SendControlFrame(_));
EXPECT_CALL(*connection_,
OnStreamReset(promise_id_, QUIC_STREAM_PEER_GOING_AWAY));
- session_.ResetStream(promise_id_, QUIC_STREAM_PEER_GOING_AWAY, 0);
+ session_.ResetStream(promise_id_, QUIC_STREAM_PEER_GOING_AWAY);
// Now initiate rendezvous.
TestPushPromiseDelegate delegate(/*match=*/true);
diff --git a/quic/core/http/quic_spdy_client_session_base.cc b/quic/core/http/quic_spdy_client_session_base.cc
index b433c56..3050989 100644
--- a/quic/core/http/quic_spdy_client_session_base.cc
+++ b/quic/core/http/quic_spdy_client_session_base.cc
@@ -204,7 +204,7 @@
QuicStreamId id,
QuicRstStreamErrorCode error_code) {
DCHECK(QuicUtils::IsServerInitiatedStreamId(transport_version(), id));
- ResetStream(id, error_code, 0);
+ ResetStream(id, error_code);
if (!IsOpenStream(id) && !IsClosedStream(id)) {
MaybeIncreaseLargestPeerStreamId(id);
}
diff --git a/quic/core/http/quic_spdy_client_session_test.cc b/quic/core/http/quic_spdy_client_session_test.cc
index 535ecf5..ea131c9 100644
--- a/quic/core/http/quic_spdy_client_session_test.cc
+++ b/quic/core/http/quic_spdy_client_session_test.cc
@@ -288,7 +288,7 @@
// Close the stream, but without having received a FIN or a RST_STREAM
// or MAX_STREAMS (V99) and check that a new one can not be created.
- session_->ResetStream(stream->id(), QUIC_STREAM_CANCELLED, 0);
+ session_->ResetStream(stream->id(), QUIC_STREAM_CANCELLED);
EXPECT_EQ(1u, QuicSessionPeer::GetNumOpenDynamicStreams(session_.get()));
stream = session_->CreateOutgoingBidirectionalStream();
@@ -304,7 +304,7 @@
EXPECT_EQ(nullptr, session_->CreateOutgoingBidirectionalStream());
// Close the stream and receive an RST frame to remove the unfinished stream
- session_->ResetStream(stream->id(), QUIC_STREAM_CANCELLED, 0);
+ session_->ResetStream(stream->id(), QUIC_STREAM_CANCELLED);
session_->OnRstStream(QuicRstStreamFrame(kInvalidControlFrameId, stream->id(),
QUIC_RST_ACKNOWLEDGEMENT, 0));
// Check that a new one can be created.
@@ -360,7 +360,7 @@
.Times(AtLeast(1))
.WillRepeatedly(Invoke(&ClearControlFrame));
EXPECT_CALL(*connection_, OnStreamReset(_, _)).Times(1);
- session_->ResetStream(stream_id, QUIC_STREAM_PEER_GOING_AWAY, 0);
+ session_->ResetStream(stream_id, QUIC_STREAM_PEER_GOING_AWAY);
// A new stream cannot be created as the reset stream still counts as an open
// outgoing stream until closed by the server.
@@ -412,7 +412,7 @@
.Times(AtLeast(1))
.WillRepeatedly(Invoke(&ClearControlFrame));
EXPECT_CALL(*connection_, OnStreamReset(_, _)).Times(1);
- session_->ResetStream(stream_id, QUIC_STREAM_PEER_GOING_AWAY, 0);
+ session_->ResetStream(stream_id, QUIC_STREAM_PEER_GOING_AWAY);
// The stream receives trailers with final byte offset, but the header value
// is non-numeric and should be treated as malformed.
@@ -862,7 +862,7 @@
EXPECT_CALL(*connection_, SendControlFrame(_));
EXPECT_CALL(*connection_,
OnStreamReset(promised_stream_id_, QUIC_STREAM_PEER_GOING_AWAY));
- session_->ResetStream(promised_stream_id_, QUIC_STREAM_PEER_GOING_AWAY, 0);
+ session_->ResetStream(promised_stream_id_, QUIC_STREAM_PEER_GOING_AWAY);
QuicClientPromisedInfo* promised =
session_->GetPromisedById(promised_stream_id_);
EXPECT_NE(promised, nullptr);
diff --git a/quic/core/http/quic_spdy_session_test.cc b/quic/core/http/quic_spdy_session_test.cc
index febbe40..20cc430 100644
--- a/quic/core/http/quic_spdy_session_test.cc
+++ b/quic/core/http/quic_spdy_session_test.cc
@@ -411,7 +411,7 @@
// handle the data.
session_.set_writev_consumes_all_data(true);
- session_.ResetStream(id, QUIC_STREAM_CANCELLED, 0);
+ session_.ResetStream(id, QUIC_STREAM_CANCELLED);
closed_streams_.insert(id);
}