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

Unified Diff: net/spdy/bidirectional_stream_spdy_impl.cc

Issue 2462463002: Make net::BidirectionalStream handle RST_STREAM_NO_ERROR (Closed)
Patch Set: self review Created 4 years, 2 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/spdy/bidirectional_stream_spdy_impl.h ('k') | net/spdy/bidirectional_stream_spdy_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/bidirectional_stream_spdy_impl.cc
diff --git a/net/spdy/bidirectional_stream_spdy_impl.cc b/net/spdy/bidirectional_stream_spdy_impl.cc
index 44ccc3a32872c6ba07e8b46183b392175861935d..b4d1a686530a4a1356d80c38807079d017944034 100644
--- a/net/spdy/bidirectional_stream_spdy_impl.cc
+++ b/net/spdy/bidirectional_stream_spdy_impl.cc
@@ -108,13 +108,8 @@ void BidirectionalStreamSpdyImpl::SendData(const scoped_refptr<IOBuffer>& data,
bool end_stream) {
DCHECK(length > 0 || (length == 0 && end_stream));
- if (!stream_) {
- LOG(ERROR) << "Trying to send data after stream has been destroyed.";
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&BidirectionalStreamSpdyImpl::NotifyError,
- weak_factory_.GetWeakPtr(), ERR_UNEXPECTED));
+ if (MaybeHandleStreamClosedInSendData())
return;
- }
DCHECK(!stream_closed_);
stream_->SendData(data.get(), length,
@@ -127,13 +122,8 @@ void BidirectionalStreamSpdyImpl::SendvData(
bool end_stream) {
DCHECK_EQ(buffers.size(), lengths.size());
- if (!stream_) {
- LOG(ERROR) << "Trying to send data after stream has been destroyed.";
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&BidirectionalStreamSpdyImpl::NotifyError,
- weak_factory_.GetWeakPtr(), ERR_UNEXPECTED));
+ if (MaybeHandleStreamClosedInSendData())
return;
- }
DCHECK(!stream_closed_);
int total_len = 0;
@@ -314,6 +304,11 @@ void BidirectionalStreamSpdyImpl::NotifyError(int rv) {
}
}
+void BidirectionalStreamSpdyImpl::NotifyDataSent() {
+ if (delegate_)
+ delegate_->OnDataSent();
+}
+
void BidirectionalStreamSpdyImpl::ResetStream() {
if (!stream_)
return;
@@ -373,4 +368,21 @@ bool BidirectionalStreamSpdyImpl::ShouldWaitForMoreBufferedData() const {
static_cast<size_t>(read_buffer_len_);
}
+bool BidirectionalStreamSpdyImpl::MaybeHandleStreamClosedInSendData() {
+ if (stream_)
+ return false;
+ // If |stream_| is closed without an error, blackhole any any write data.
+ if (stream_closed_ && closed_stream_status_ == OK) {
kapishnikov 2016/10/28 16:11:00 If the stream was closed because all data were sen
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&BidirectionalStreamSpdyImpl::NotifyDataSent,
+ weak_factory_.GetWeakPtr()));
+ return true;
+ }
+ LOG(ERROR) << "Trying to send data after stream has been destroyed.";
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&BidirectionalStreamSpdyImpl::NotifyError,
+ weak_factory_.GetWeakPtr(), ERR_UNEXPECTED));
+ return true;
+}
+
} // namespace net
« no previous file with comments | « net/spdy/bidirectional_stream_spdy_impl.h ('k') | net/spdy/bidirectional_stream_spdy_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698