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

Unified Diff: net/proxy/proxy_script_fetcher_impl.cc

Issue 2265873002: Adjust callers and networking delegates in net/ to modified APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLRequestRead
Patch Set: rebased Created 4 years, 4 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/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 bd3c46a9f28888cb6f74df40e661853ac8209c8e..eabc2ea3810e7a5027edc12f341087b9f7a5f080 100644
--- a/net/proxy/proxy_script_fetcher_impl.cc
+++ b/net/proxy/proxy_script_fetcher_impl.cc
@@ -104,13 +104,14 @@ size_t ProxyScriptFetcherImpl::SetSizeConstraint(size_t size_bytes) {
return prev;
}
-void ProxyScriptFetcherImpl::OnResponseCompleted(URLRequest* request) {
+void ProxyScriptFetcherImpl::OnResponseCompleted(URLRequest* request,
+ int net_error) {
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 && !request->status().is_success())
- result_code_ = request->status().error();
+ if (result_code_ == OK && net_error != OK)
+ result_code_ = net_error;
FetchCompleted();
}
@@ -206,11 +207,13 @@ void ProxyScriptFetcherImpl::OnSSLCertificateError(URLRequest* request,
request->Cancel();
}
-void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request) {
+void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request,
+ int net_error) {
DCHECK_EQ(request, cur_request_.get());
+ DCHECK_NE(ERR_IO_PENDING, net_error);
- if (!request->status().is_success()) {
- OnResponseCompleted(request);
+ if (net_error != OK) {
+ OnResponseCompleted(request, net_error);
return;
}
@@ -242,6 +245,8 @@ void ProxyScriptFetcherImpl::OnResponseStarted(URLRequest* request) {
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.
@@ -252,11 +257,11 @@ void ProxyScriptFetcherImpl::OnReadCompleted(URLRequest* request,
void ProxyScriptFetcherImpl::ReadBody(URLRequest* request) {
// Read as many bytes as are available synchronously.
while (true) {
- int num_bytes;
- if (!request->Read(buf_.get(), kBufSize, &num_bytes)) {
+ int num_bytes = request->Read(buf_.get(), kBufSize);
+ if (num_bytes < 0) {
// Check whether the read failed synchronously.
- if (!request->status().is_io_pending())
- OnResponseCompleted(request);
+ if (num_bytes != ERR_IO_PENDING)
+ OnResponseCompleted(request, num_bytes);
return;
}
mmenke 2016/08/30 22:13:22 Think this is clearer as: if (num_bytes == ERR_IO
maksims (do not use this acc) 2016/09/01 12:22:30 Done.
if (!ConsumeBytesRead(request, num_bytes))
@@ -268,7 +273,7 @@ bool ProxyScriptFetcherImpl::ConsumeBytesRead(URLRequest* request,
int num_bytes) {
if (num_bytes <= 0) {
// Error while reading, or EOF.
- OnResponseCompleted(request);
+ OnResponseCompleted(request, num_bytes);
return false;
}

Powered by Google App Engine
This is Rietveld 408576698