Index: net/proxy/proxy_script_fetcher_impl.cc |
diff --git a/net/proxy/proxy_script_fetcher_impl.cc b/net/proxy/proxy_script_fetcher_impl.cc |
index d78c9feb65a5df03252977a2594e24f285fd4cc1..bd3c46a9f28888cb6f74df40e661853ac8209c8e 100644 |
--- a/net/proxy/proxy_script_fetcher_impl.cc |
+++ b/net/proxy/proxy_script_fetcher_impl.cc |
@@ -104,14 +104,13 @@ |
return prev; |
} |
-void ProxyScriptFetcherImpl::OnResponseCompleted(URLRequest* request, |
- int net_error) { |
+void ProxyScriptFetcherImpl::OnResponseCompleted(URLRequest* request) { |
DCHECK_EQ(request, cur_request_.get()); |
// Use |result_code_| as the request's error if we have already set it to |
// something specific. |
- if (result_code_ == OK && net_error != OK) |
- result_code_ = net_error; |
+ if (result_code_ == OK && !request->status().is_success()) |
+ result_code_ = request->status().error(); |
FetchCompleted(); |
} |
@@ -207,13 +206,11 @@ |
request->Cancel(); |
} |
-void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request, |
- int net_error) { |
- DCHECK_EQ(request, cur_request_.get()); |
- DCHECK_NE(ERR_IO_PENDING, net_error); |
- |
- if (net_error != OK) { |
- OnResponseCompleted(request, net_error); |
+void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request) { |
+ DCHECK_EQ(request, cur_request_.get()); |
+ |
+ if (!request->status().is_success()) { |
+ OnResponseCompleted(request); |
return; |
} |
@@ -245,8 +242,6 @@ |
void ProxyScriptFetcherImpl::OnReadCompleted(URLRequest* request, |
int num_bytes) { |
- DCHECK_NE(ERR_IO_PENDING, num_bytes); |
- |
DCHECK_EQ(request, cur_request_.get()); |
if (ConsumeBytesRead(request, num_bytes)) { |
// Keep reading. |
@@ -257,15 +252,13 @@ |
void ProxyScriptFetcherImpl::ReadBody(URLRequest* request) { |
// Read as many bytes as are available synchronously. |
while (true) { |
- int num_bytes = request->Read(buf_.get(), kBufSize); |
- if (num_bytes == ERR_IO_PENDING) |
- return; |
- |
- if (num_bytes < 0) { |
- OnResponseCompleted(request, num_bytes); |
+ int num_bytes; |
+ if (!request->Read(buf_.get(), kBufSize, &num_bytes)) { |
+ // Check whether the read failed synchronously. |
+ if (!request->status().is_io_pending()) |
+ OnResponseCompleted(request); |
return; |
} |
- |
if (!ConsumeBytesRead(request, num_bytes)) |
return; |
} |
@@ -275,7 +268,7 @@ |
int num_bytes) { |
if (num_bytes <= 0) { |
// Error while reading, or EOF. |
- OnResponseCompleted(request, num_bytes); |
+ OnResponseCompleted(request); |
return false; |
} |