Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: net/quic/core/quic_stream.cc

Issue 2916233002: Remove is_deletable_ from QuicStream. Add QuicStream::IsWaitingForAcks (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/quic_stream.h ('k') | net/quic/core/quic_stream_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/quic_stream.cc
diff --git a/net/quic/core/quic_stream.cc b/net/quic/core/quic_stream.cc
index 6e9b2bd2acf947a950923a3bc9d8ab663b825530..95d91e4b2de26935774d8f8d550167a75dfe6212 100644
--- a/net/quic/core/quic_stream.cc
+++ b/net/quic/core/quic_stream.cc
@@ -65,7 +65,6 @@ QuicStream::QuicStream(QuicStreamId id, QuicSession* session)
fin_received_(false),
rst_sent_(false),
rst_received_(false),
- is_deletable_(true),
perspective_(session_->perspective()),
flow_controller_(session_->connection(),
id_,
@@ -83,8 +82,8 @@ QuicStream::QuicStream(QuicStreamId id, QuicSession* session)
}
QuicStream::~QuicStream() {
- QUIC_LOG_IF(WARNING, !is_deletable_)
- << "Stream destroyed while not deletable.";
+ QUIC_LOG_IF(WARNING, !IsWaitingForAcks())
+ << "Stream destroyed while waiting for acks.";
}
void QuicStream::SetFromConfig() {}
@@ -150,10 +149,6 @@ void QuicStream::OnStreamReset(const QuicRstStreamFrame& frame) {
void QuicStream::OnConnectionClosed(QuicErrorCode error,
ConnectionCloseSource /*source*/) {
- if (session()->use_stream_notifier()) {
- // Connection is closed, consider this stream as deletable.
- SetIsDeletable(true);
- }
if (read_side_closed_ && write_side_closed_) {
return;
}
@@ -182,9 +177,8 @@ void QuicStream::Reset(QuicRstStreamErrorCode error) {
// Sending a RstStream results in calling CloseStream.
session()->SendRstStream(id(), error, stream_bytes_written_);
rst_sent_ = true;
- if (session()->use_stream_notifier() && error != QUIC_STREAM_NO_ERROR) {
- // This stream is deletable as data is not going to be retransmitted.
- SetIsDeletable(true);
+ if (session()->use_stream_notifier() && !IsWaitingForAcks()) {
+ session_->OnStreamDoneWaitingForAcks(id_);
}
}
@@ -364,13 +358,6 @@ QuicConsumedData QuicStream::WritevData(
if (consumed_data.bytes_consumed > 0 || consumed_data.fin_consumed) {
busy_counter_ = 0;
}
- if (session()->use_stream_notifier() &&
- (stream_bytes_written_ > stream_bytes_acked_ ||
- (fin && consumed_data.fin_consumed))) {
- // This stream is considered not deletable when it has unacked data
- // (including FIN).
- SetIsDeletable(false);
- }
return consumed_data;
}
@@ -514,13 +501,6 @@ void QuicStream::AddRandomPaddingAfterFin() {
add_random_padding_after_fin_ = true;
}
-void QuicStream::SetIsDeletable(bool is_deletable) {
- is_deletable_ = is_deletable;
- if (is_deletable) {
- session_->MarkStreamDeletable(id_);
- }
-}
-
void QuicStream::OnStreamFrameAcked(const QuicStreamFrame& frame,
QuicTime::Delta ack_delay_time) {
DCHECK_EQ(frame.stream_id, id());
@@ -536,11 +516,8 @@ void QuicStream::OnStreamFrameAcked(const QuicStreamFrame& frame,
if (ack_listener_ != nullptr) {
ack_listener_->OnPacketAcked(frame.data_length, ack_delay_time);
}
- if (stream_bytes_acked_ == stream_bytes_written_ &&
- ((fin_sent_ && fin_acked_) || !fin_sent_)) {
- // This stream is considered deletable when all sent bytes are acked
- // (including FIN).
- SetIsDeletable(true);
+ if (!IsWaitingForAcks()) {
+ session_->OnStreamDoneWaitingForAcks(id_);
}
}
@@ -550,4 +527,22 @@ void QuicStream::OnStreamFrameRetransmitted(const QuicStreamFrame& frame) {
}
}
+bool QuicStream::IsWaitingForAcks() const {
+ if (rst_sent_ && stream_error_ != QUIC_STREAM_NO_ERROR) {
+ // RST_STREAM sent because of error.
+ return false;
+ }
+ if (connection_error_ != QUIC_NO_ERROR) {
+ // Connection encounters error and is going to close.
+ return false;
+ }
+ if (stream_bytes_acked_ == stream_bytes_written_ &&
+ ((fin_sent_ && fin_acked_) || !fin_sent_)) {
+ // All sent data has been acked.
+ return false;
+ }
+
+ return true;
+}
+
} // namespace net
« no previous file with comments | « net/quic/core/quic_stream.h ('k') | net/quic/core/quic_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698