Chromium Code Reviews| Index: components/cronet/android/url_request_adapter.cc |
| diff --git a/components/cronet/android/url_request_adapter.cc b/components/cronet/android/url_request_adapter.cc |
| index 535c67e66cbb91be1842281fa0a8e2e5954a6afd..9b8f419e5ac3728c8c621843c85fbc0760904b11 100644 |
| --- a/components/cronet/android/url_request_adapter.cc |
| +++ b/components/cronet/android/url_request_adapter.cc |
| @@ -210,10 +210,13 @@ void URLRequestAdapter::OnDestroyRequest(URLRequestAdapter* self) { |
| } |
| // static |
| -void URLRequestAdapter::OnResponseStarted(net::URLRequest* request) { |
| +void URLRequestAdapter::OnResponseStarted(net::URLRequest* request, |
| + int net_error) { |
| + DCHECK_NE(net::ERR_IO_PENDING, net_error); |
| DCHECK(OnNetworkThread()); |
| - if (request->status().status() != net::URLRequestStatus::SUCCESS) { |
| - OnRequestFailed(); |
| + |
| + if (net_error != net::OK) { |
| + OnRequestFailed(net_error); |
| return; |
| } |
| @@ -238,10 +241,9 @@ void URLRequestAdapter::Read() { |
| read_buffer_ = new net::IOBufferWithSize(kReadBufferSize); |
| while(true) { |
| - int bytes_read = 0; |
| - url_request_->Read(read_buffer_.get(), kReadBufferSize, &bytes_read); |
| + int bytes_read = url_request_->Read(read_buffer_.get(), kReadBufferSize); |
|
mmenke
2016/09/06 17:57:58
nit: bytes_read -> result
|
| // If IO is pending, wait for the URLRequest to call OnReadCompleted. |
| - if (url_request_->status().is_io_pending()) |
| + if (bytes_read == net::ERR_IO_PENDING) |
| return; |
| // Stop when request has failed or succeeded. |
| if (!HandleReadResult(bytes_read)) |
| @@ -251,8 +253,9 @@ void URLRequestAdapter::Read() { |
| bool URLRequestAdapter::HandleReadResult(int bytes_read) { |
|
mmenke
2016/09/06 17:57:58
bytes_read -> result
|
| DCHECK(OnNetworkThread()); |
| - if (!url_request_->status().is_success()) { |
| - OnRequestFailed(); |
| + if (bytes_read < 0) { |
| + int net_error = bytes_read; |
| + OnRequestFailed(net_error); |
| return false; |
| } else if (bytes_read == 0) { |
|
mmenke
2016/09/06 17:57:58
pre-existing issue, but while you're here, mind re
maksims (do not use this acc)
2016/09/12 12:11:54
Do you mean to do this -
if (result == 0) {
..
|
| OnRequestSucceeded(); |
| @@ -267,6 +270,7 @@ bool URLRequestAdapter::HandleReadResult(int bytes_read) { |
| void URLRequestAdapter::OnReadCompleted(net::URLRequest* request, |
| int bytes_read) { |
| + DCHECK_NE(net::ERR_IO_PENDING, bytes_read); |
| if (!HandleReadResult(bytes_read)) |
| return; |
| @@ -299,15 +303,14 @@ void URLRequestAdapter::OnRequestSucceeded() { |
| OnRequestCompleted(); |
| } |
| -void URLRequestAdapter::OnRequestFailed() { |
| +void URLRequestAdapter::OnRequestFailed(int net_error) { |
|
mmenke
2016/09/06 17:57:58
Suggest adding:
DCHECK_LE(net_error, 0);
DCHECK_N
maksims (do not use this acc)
2016/09/12 12:11:54
Done.
|
| DCHECK(OnNetworkThread()); |
| if (canceled_) { |
| return; |
| } |
| - error_code_ = url_request_->status().error(); |
| - VLOG(1) << "Request failed with status: " << url_request_->status().status() |
| - << " and error: " << net::ErrorToString(error_code_); |
| + error_code_ = net_error; |
| + VLOG(1) << "Request failed with error: " << net::ErrorToString(error_code_); |
| OnRequestCompleted(); |
| } |