| 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 a8531d961a5f1ebeb116d2e6554c3de3c435191b..f8a75c349af2729ae7bfd0926d3860ead8354421 100644
|
| --- a/net/spdy/bidirectional_stream_spdy_impl.cc
|
| +++ b/net/spdy/bidirectional_stream_spdy_impl.cc
|
| @@ -60,7 +60,10 @@ void BidirectionalStreamSpdyImpl::Start(
|
| timer_ = std::move(timer);
|
|
|
| if (!spdy_session_) {
|
| - delegate_->OnFailed(ERR_CONNECTION_CLOSED);
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&BidirectionalStreamSpdyImpl::NotifyError,
|
| + weak_factory_.GetWeakPtr(), ERR_CONNECTION_CLOSED));
|
| return;
|
| }
|
|
|
| @@ -104,8 +107,15 @@ int BidirectionalStreamSpdyImpl::ReadData(IOBuffer* buf, int buf_len) {
|
| void BidirectionalStreamSpdyImpl::SendData(const scoped_refptr<IOBuffer>& data,
|
| int length,
|
| bool end_stream) {
|
| - DCHECK(!stream_closed_);
|
| - DCHECK(stream_);
|
| + DCHECK(length > 0 || (length == 0 && end_stream));
|
| +
|
| + if (!stream_) {
|
| + LOG(ERROR) << "Trying to send data when stream has been destroyed.";
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE, base::Bind(&BidirectionalStreamSpdyImpl::NotifyError,
|
| + weak_factory_.GetWeakPtr(), ERR_UNEXPECTED));
|
| + return;
|
| + }
|
|
|
| stream_->SendData(data.get(), length,
|
| end_stream ? NO_MORE_DATA_TO_SEND : MORE_DATA_TO_SEND);
|
| @@ -115,10 +125,16 @@ void BidirectionalStreamSpdyImpl::SendvData(
|
| const std::vector<scoped_refptr<IOBuffer>>& buffers,
|
| const std::vector<int>& lengths,
|
| bool end_stream) {
|
| - DCHECK(!stream_closed_);
|
| - DCHECK(stream_);
|
| DCHECK_EQ(buffers.size(), lengths.size());
|
|
|
| + if (!stream_) {
|
| + LOG(ERROR) << "Trying to send data when stream has been destroyed.";
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE, base::Bind(&BidirectionalStreamSpdyImpl::NotifyError,
|
| + weak_factory_.GetWeakPtr(), ERR_UNEXPECTED));
|
| + return;
|
| + }
|
| +
|
| int total_len = 0;
|
| for (int len : lengths) {
|
| total_len += len;
|
| @@ -228,7 +244,7 @@ void BidirectionalStreamSpdyImpl::OnClose(int status) {
|
| stream_.reset();
|
|
|
| if (status != OK) {
|
| - delegate_->OnFailed(status);
|
| + NotifyError(status);
|
| return;
|
| }
|
| // Complete any remaining read, as all data has been buffered.
|
| @@ -267,6 +283,10 @@ void BidirectionalStreamSpdyImpl::OnStreamInitialized(int rv) {
|
| return;
|
| }
|
| }
|
| + NotifyError(rv);
|
| +}
|
| +
|
| +void BidirectionalStreamSpdyImpl::NotifyError(int rv) {
|
| delegate_->OnFailed(rv);
|
| }
|
|
|
|
|