Chromium Code Reviews| 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 |