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..3548e59316b603a8610632692da725f7b8ac1c15 100644 |
--- a/net/proxy/proxy_script_fetcher_impl.cc |
+++ b/net/proxy/proxy_script_fetcher_impl.cc |
@@ -123,6 +123,9 @@ int ProxyScriptFetcherImpl::Fetch( |
DCHECK(!callback.is_null()); |
DCHECK(text); |
+ if (!url_request_context_) |
+ return ERR_CONTEXT_SHUT_DOWN; |
+ |
// Handle base-64 encoded data-urls that contain custom PAC scripts. |
if (url.SchemeIs("data")) { |
std::string mime_type; |
@@ -138,8 +141,10 @@ int ProxyScriptFetcherImpl::Fetch( |
DCHECK(fetch_start_time_.is_null()); |
fetch_start_time_ = base::TimeTicks::Now(); |
+ // Use highest priority, so if socket pools are being used for other types of |
+ // requests, PAC requests are aren't blocked on them. |
cur_request_ = |
- url_request_context_->CreateRequest(url, DEFAULT_PRIORITY, this); |
+ url_request_context_->CreateRequest(url, MAXIMUM_PRIORITY, this); |
cur_request_->set_method("GET"); |
// Make sure that the PAC script is downloaded using a direct connection, |
@@ -150,9 +155,11 @@ int ProxyScriptFetcherImpl::Fetch( |
// If the PAC script is hosted on an HTTPS server we bypass revocation |
// checking in order to avoid a circular dependency when attempting to fetch |
// the OCSP response or CRL. We could make the revocation check go direct but |
- // the proxy might be the only way to the outside world. |
+ // the proxy might be the only way to the outside world. IGNORE_LIMITS is |
+ // used to avoid blocking proxy resolution on other network requests. |
cur_request_->SetLoadFlags(LOAD_BYPASS_PROXY | LOAD_DISABLE_CACHE | |
- LOAD_DISABLE_CERT_REVOCATION_CHECKING); |
+ LOAD_DISABLE_CERT_REVOCATION_CHECKING | |
+ LOAD_IGNORE_LIMITS); |
// Save the caller's info for notification on completion. |
callback_ = callback; |
@@ -183,6 +190,15 @@ URLRequestContext* ProxyScriptFetcherImpl::GetRequestContext() const { |
return url_request_context_; |
} |
+void ProxyScriptFetcherImpl::OnShutdown() { |
+ url_request_context_ = nullptr; |
+ |
+ if (cur_request_) { |
+ result_code_ = ERR_CONTEXT_SHUT_DOWN; |
+ FetchCompleted(); |
+ } |
+} |
+ |
void ProxyScriptFetcherImpl::OnAuthRequired(URLRequest* request, |
AuthChallengeInfo* auth_info) { |
DCHECK_EQ(request, cur_request_.get()); |
@@ -341,7 +357,7 @@ void ProxyScriptFetcherImpl::OnTimeout(int id) { |
DCHECK(cur_request_.get()); |
result_code_ = ERR_TIMED_OUT; |
- cur_request_->Cancel(); |
+ FetchCompleted(); |
} |
} // namespace net |