Commit 2a6316cb authored by Bence Béky's avatar Bence Béky Committed by Commit Bot

Remove ReadResponseBody() call with null callback.

Remove the ReadResponseBody() call with null callback introduced in
https://crrev.com/c/913790, and restore the CHECK in ReadResponseBody().
Also do some cleanup to make OnClose() and DoBufferedReadCallback()
easier to read.

Change-Id: I81680d7ae7a500df3b184ff0b8a0f98bc9ce6d76
Reviewed-on: https://chromium-review.googlesource.com/917062Reviewed-by: default avatarRandy Smith <rdsmith@chromium.org>
Commit-Queue: Bence Béky <bnc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537519}
parent eaed2462
...@@ -133,6 +133,7 @@ int SpdyHttpStream::ReadResponseBody(IOBuffer* buf, ...@@ -133,6 +133,7 @@ int SpdyHttpStream::ReadResponseBody(IOBuffer* buf,
CHECK(buf); CHECK(buf);
CHECK(buf_len); CHECK(buf_len);
CHECK(!callback.is_null());
// If we have data buffered, complete the IO immediately. // If we have data buffered, complete the IO immediately.
if (!response_body_queue_.IsEmpty()) { if (!response_body_queue_.IsEmpty()) {
...@@ -141,7 +142,6 @@ int SpdyHttpStream::ReadResponseBody(IOBuffer* buf, ...@@ -141,7 +142,6 @@ int SpdyHttpStream::ReadResponseBody(IOBuffer* buf,
return closed_stream_status_; return closed_stream_status_;
} }
CHECK(!callback.is_null());
CHECK(response_callback_.is_null()); CHECK(response_callback_.is_null());
CHECK(!user_buffer_.get()); CHECK(!user_buffer_.get());
CHECK_EQ(0, user_buffer_len_); CHECK_EQ(0, user_buffer_len_);
...@@ -368,19 +368,19 @@ void SpdyHttpStream::OnDataSent() { ...@@ -368,19 +368,19 @@ void SpdyHttpStream::OnDataSent() {
void SpdyHttpStream::OnTrailers(const SpdyHeaderBlock& trailers) {} void SpdyHttpStream::OnTrailers(const SpdyHeaderBlock& trailers) {}
void SpdyHttpStream::OnClose(int status) { void SpdyHttpStream::OnClose(int status) {
DCHECK(stream_);
// Cancel any pending reads from the upload data stream. // Cancel any pending reads from the upload data stream.
if (request_info_ && request_info_->upload_data_stream) if (request_info_ && request_info_->upload_data_stream)
request_info_->upload_data_stream->Reset(); request_info_->upload_data_stream->Reset();
if (stream_) { stream_closed_ = true;
stream_closed_ = true; closed_stream_status_ = status;
closed_stream_status_ = status; closed_stream_id_ = stream_->stream_id();
closed_stream_id_ = stream_->stream_id(); closed_stream_has_load_timing_info_ =
closed_stream_has_load_timing_info_ = stream_->GetLoadTimingInfo(&closed_stream_load_timing_info_);
stream_->GetLoadTimingInfo(&closed_stream_load_timing_info_); closed_stream_received_bytes_ = stream_->raw_received_bytes();
closed_stream_received_bytes_ = stream_->raw_received_bytes(); closed_stream_sent_bytes_ = stream_->raw_sent_bytes();
closed_stream_sent_bytes_ = stream_->raw_sent_bytes();
}
stream_ = nullptr; stream_ = nullptr;
// Callbacks might destroy |this|. // Callbacks might destroy |this|.
...@@ -526,13 +526,11 @@ void SpdyHttpStream::DoBufferedReadCallback() { ...@@ -526,13 +526,11 @@ void SpdyHttpStream::DoBufferedReadCallback() {
// If the transaction is cancelled or errored out, we don't need to complete // If the transaction is cancelled or errored out, we don't need to complete
// the read. // the read.
if (!stream_ && !stream_closed_) if (stream_closed_ && closed_stream_status_ != OK) {
return; if (response_callback_)
DoResponseCallback(closed_stream_status_);
int stream_status =
stream_closed_ ? closed_stream_status_ : stream_->response_status();
if (stream_status != OK)
return; return;
}
// When more_read_data_pending_ is true, it means that more data has // When more_read_data_pending_ is true, it means that more data has
// arrived since we started waiting. Wait a little longer and continue // arrived since we started waiting. Wait a little longer and continue
...@@ -542,18 +540,20 @@ void SpdyHttpStream::DoBufferedReadCallback() { ...@@ -542,18 +540,20 @@ void SpdyHttpStream::DoBufferedReadCallback() {
return; return;
} }
int rv = 0; if (!user_buffer_.get())
if (user_buffer_.get()) { return;
// At this point SpdyHttpStream::ReadResponseBody() is guaranteed to return
// synchronously for non-trivial reasons, therefore it is safe to call it if (!response_body_queue_.IsEmpty()) {
// with a null callback. int rv =
rv = ReadResponseBody(user_buffer_.get(), user_buffer_len_, response_body_queue_.Dequeue(user_buffer_->data(), user_buffer_len_);
CompletionOnceCallback()); user_buffer_ = nullptr;
CHECK_NE(rv, ERR_IO_PENDING);
user_buffer_ = NULL;
user_buffer_len_ = 0; user_buffer_len_ = 0;
DoResponseCallback(rv); DoResponseCallback(rv);
return;
} }
if (stream_closed_ && response_callback_)
DoResponseCallback(closed_stream_status_);
} }
void SpdyHttpStream::DoRequestCallback(int rv) { void SpdyHttpStream::DoRequestCallback(int rv) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment