| 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 5d2ae0445bd8c4126f750d7d803060f4cae81154..d581acd3d1966622293c8d9a014d8a6067b884c7 100644
|
| --- a/net/quic/chromium/bidirectional_stream_quic_impl.cc
|
| +++ b/net/quic/chromium/bidirectional_stream_quic_impl.cc
|
| @@ -81,6 +81,10 @@ void BidirectionalStreamQuicImpl::Start(
|
| }
|
|
|
| void BidirectionalStreamQuicImpl::SendRequestHeaders() {
|
| + WriteHeaders();
|
| +}
|
| +
|
| +bool BidirectionalStreamQuicImpl::WriteHeaders() {
|
| DCHECK(!has_sent_headers_);
|
| if (!stream_) {
|
| LOG(ERROR)
|
| @@ -88,7 +92,7 @@ void BidirectionalStreamQuicImpl::SendRequestHeaders() {
|
| base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::NotifyError,
|
| weak_factory_.GetWeakPtr(), ERR_UNEXPECTED));
|
| - return;
|
| + return false;
|
| }
|
|
|
| SpdyHeaderBlock headers;
|
| @@ -104,9 +108,11 @@ void BidirectionalStreamQuicImpl::SendRequestHeaders() {
|
| size_t headers_bytes_sent = stream_->WriteHeaders(
|
| std::move(headers), request_info_->end_stream_on_headers, nullptr);
|
| if (!guard.get())
|
| - return;
|
| + return false;
|
| +
|
| headers_bytes_sent_ += headers_bytes_sent;
|
| has_sent_headers_ = true;
|
| + return true;
|
| }
|
|
|
| int BidirectionalStreamQuicImpl::ReadData(IOBuffer* buffer, int buffer_len) {
|
| @@ -157,7 +163,9 @@ void BidirectionalStreamQuicImpl::SendData(const scoped_refptr<IOBuffer>& data,
|
| // single data buffer.
|
| bundler =
|
| session_->CreatePacketBundler(QuicConnection::SEND_ACK_IF_PENDING);
|
| - SendRequestHeaders();
|
| + // Sending the request might result in |this| being deleted.
|
| + if (!WriteHeaders())
|
| + return;
|
| }
|
|
|
| QuicStringPiece string_data(data->data(), length);
|
| @@ -191,7 +199,9 @@ void BidirectionalStreamQuicImpl::SendvData(
|
| session_->CreatePacketBundler(QuicConnection::SEND_ACK_IF_PENDING));
|
| if (!has_sent_headers_) {
|
| DCHECK(!send_request_headers_automatically_);
|
| - SendRequestHeaders();
|
| + // Sending the request might result in |this| being deleted.
|
| + if (!WriteHeaders())
|
| + return;
|
| }
|
|
|
| int rv = stream_->WritevStreamData(
|
| @@ -374,13 +384,10 @@ void BidirectionalStreamQuicImpl::NotifyError(int error) {
|
| }
|
|
|
| void BidirectionalStreamQuicImpl::NotifyStreamReady() {
|
| - if (send_request_headers_automatically_) {
|
| - // Sending the request might result in |this| being deleted.
|
| - auto guard = weak_factory_.GetWeakPtr();
|
| - SendRequestHeaders();
|
| - if (!guard.get())
|
| - return;
|
| - }
|
| + // Sending the request might result in |this| being deleted.
|
| + if (send_request_headers_automatically_ && !WriteHeaders())
|
| + return;
|
| +
|
| if (delegate_)
|
| delegate_->OnStreamReady(has_sent_headers_);
|
| }
|
|
|