Chromium Code Reviews| Index: net/quic/chromium/bidirectional_stream_quic_impl.cc |
| diff --git a/net/quic/chromium/bidirectional_stream_quic_impl.cc b/net/quic/chromium/bidirectional_stream_quic_impl.cc |
| index 7645f8a36b0ed0071c90163eb8ae7e8fbdb5b85d..6aaaf725fb65f1f582636ad57f53edee7c5f55a2 100644 |
| --- a/net/quic/chromium/bidirectional_stream_quic_impl.cc |
| +++ b/net/quic/chromium/bidirectional_stream_quic_impl.cc |
| @@ -246,8 +246,15 @@ void BidirectionalStreamQuicImpl::OnHeadersAvailable( |
| // BidirectionalStreamQuicImpl::OnClose(). |
| stream_->OnFinRead(); |
| } |
| - if (delegate_) |
| - delegate_->OnTrailersReceived(headers); |
| + if (!delegate_) |
| + return; |
| + // Complete any remaining read. The task is posted because |
| + // |delegate_|->OnTrailersReceived() might destroy |this|. |
| + base::ThreadTaskRunnerHandle::Get()->PostTask( |
| + FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::OnDataAvailable, |
| + weak_factory_.GetWeakPtr())); |
| + delegate_->OnTrailersReceived(headers); |
| + // |this| can be destroyed after this point. |
| } |
| } |
| @@ -256,8 +263,8 @@ void BidirectionalStreamQuicImpl::OnDataAvailable() { |
| if (!read_buffer_) |
| return; |
| - CHECK(read_buffer_); |
| - CHECK_NE(0, read_buffer_len_); |
| + DCHECK(read_buffer_); |
|
kapishnikov
2016/10/05 21:05:08
Can we remove this DCHECK? The previous 'if' state
xunjieli
2016/10/05 21:56:28
Done. Ah, you are right. Not sure why I added thos
|
| + DCHECK_NE(0, read_buffer_len_); |
| int rv = ReadData(read_buffer_.get(), read_buffer_len_); |
| if (rv == ERR_IO_PENDING) { |
| // Spurrious notification. Wait for the next one. |