Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Unified Diff: net/spdy/spdy_http_stream.cc

Issue 2022053002: Introduce error handling in SpdyHttpStream on UploadDataStream::Read() failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/spdy/spdy_http_stream.cc
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc
index 259581a5229173cc2e7fcbc84963396f357c0d80..8891b0abe5d401579fb7137e1b2214400c09bd7b 100644
--- a/net/spdy/spdy_http_stream.cc
+++ b/net/spdy/spdy_http_stream.cc
@@ -302,13 +302,15 @@ void SpdyHttpStream::Cancel() {
}
void SpdyHttpStream::OnRequestHeadersSent() {
- if (!request_callback_.is_null())
- DoRequestCallback(OK);
-
// TODO(akalin): Do this immediately after sending the request
// headers.
- if (HasUploadData())
+ if (HasUploadData()) {
ReadAndSendRequestBodyData();
+ return;
+ }
+
+ if (!request_callback_.is_null())
+ DoRequestCallback(OK);
}
SpdyResponseHeadersStatus SpdyHttpStream::OnResponseHeadersUpdated(
@@ -448,25 +450,41 @@ void SpdyHttpStream::ReadAndSendRequestBodyData() {
weak_factory_.GetWeakPtr()));
if (rv != ERR_IO_PENDING) {
- // ERR_IO_PENDING is the only possible error.
- CHECK_GE(rv, 0);
+ // UploadDataStream::Read() can fail reading data
OnRequestBodyReadCompleted(rv);
}
}
+void SpdyHttpStream::ResetStreamInternal() {
+ spdy_session_->ResetStream(stream()->stream_id(), RST_STREAM_INTERNAL_ERROR,
+ std::string());
+}
+
void SpdyHttpStream::OnRequestBodyReadCompleted(int status) {
- CHECK_GE(status, 0);
- request_body_buf_size_ = status;
- const bool eof = request_info_->upload_data_stream->IsEOF();
- // Only the final fame may have a length of 0.
- if (eof) {
- CHECK_GE(request_body_buf_size_, 0);
+ if (status < 0) {
+ DCHECK_NE(ERR_IO_PENDING, status);
+
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&SpdyHttpStream::ResetStreamInternal,
+ weak_factory_.GetWeakPtr()));
} else {
- CHECK_GT(request_body_buf_size_, 0);
+ CHECK_GE(status, 0);
+ request_body_buf_size_ = status;
+ const bool eof = request_info_->upload_data_stream->IsEOF();
+ // Only the final fame may have a length of 0.
+ if (eof) {
+ CHECK_GE(request_body_buf_size_, 0);
+ } else {
+ CHECK_GT(request_body_buf_size_, 0);
+ }
+ stream_->SendData(request_body_buf_.get(), request_body_buf_size_,
+ eof ? NO_MORE_DATA_TO_SEND : MORE_DATA_TO_SEND);
+ }
+
+ if (!request_callback_.is_null()) {
+ int result = status > 0 ? OK : status;
+ DoRequestCallback(result);
}
- stream_->SendData(request_body_buf_.get(),
- request_body_buf_size_,
- eof ? NO_MORE_DATA_TO_SEND : MORE_DATA_TO_SEND);
}
void SpdyHttpStream::ScheduleBufferedReadCallback() {

Powered by Google App Engine
This is Rietveld 408576698