Index: components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc |
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc |
index 5fc9213ec3c6fd04c11bd95f5d06726de20c929f..67b101115640cbd0779c00339a3cc44e72e75c42 100644 |
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc |
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc |
@@ -304,6 +304,12 @@ DataReductionProxySettings::GetDailyReceivedContentLengths() { |
void DataReductionProxySettings::OnURLFetchComplete( |
const net::URLFetcher* source) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
+ |
+ // The purpose of sending a request for the warmup URL is to warm the |
+ // connection to the data_reduction_proxy. The result is ignored. |
+ if (source == warmup_fetcher_.get()) |
+ return; |
+ |
marq (ping after 24h)
2014/06/16 17:23:35
DCHECK(source == fetcher_.get()), so that adding a
bengr
2014/06/17 03:42:09
Done.
|
net::URLRequestStatus status = source->GetStatus(); |
if (status.status() == net::URLRequestStatus::FAILED && |
status.error() == net::ERR_INTERNET_DISCONNECTED) { |
@@ -399,6 +405,7 @@ void DataReductionProxySettings::OnIPAddressChanged() { |
if (enabled_by_user_) { |
DCHECK(params_->allowed()); |
ProbeWhetherDataReductionProxyIsAvailable(); |
+ WarmProxyConnection(); |
} |
} |
@@ -451,8 +458,10 @@ void DataReductionProxySettings::MaybeActivateDataReductionProxy( |
at_startup); |
// Check if the proxy has been restricted explicitly by the carrier. |
- if (enabled_by_user_) |
+ if (enabled_by_user_) { |
ProbeWhetherDataReductionProxyIsAvailable(); |
+ WarmProxyConnection(); |
+ } |
} |
void DataReductionProxySettings::SetProxyConfigs(bool enabled, |
@@ -581,12 +590,15 @@ base::string16 DataReductionProxySettings::AuthHashForSalt( |
return base::UTF8ToUTF16(base::MD5String(salted_key)); |
} |
-net::URLFetcher* DataReductionProxySettings::GetURLFetcher() { |
- DCHECK(url_request_context_getter_); |
- net::URLFetcher* fetcher = net::URLFetcher::Create(params_->probe_url(), |
+net::URLFetcher* DataReductionProxySettings::GetBaseURLFetcher( |
+ const GURL& gurl, |
+ int load_flags) { |
+ |
+ net::URLFetcher* fetcher = net::URLFetcher::Create(gurl, |
net::URLFetcher::GET, |
this); |
- fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | net::LOAD_BYPASS_PROXY); |
+ fetcher->SetLoadFlags(load_flags); |
+ DCHECK(url_request_context_getter_); |
fetcher->SetRequestContext(url_request_context_getter_); |
// Configure max retries to be at most kMaxRetries times for 5xx errors. |
static const int kMaxRetries = 5; |
@@ -595,6 +607,13 @@ net::URLFetcher* DataReductionProxySettings::GetURLFetcher() { |
return fetcher; |
} |
+ |
+net::URLFetcher* DataReductionProxySettings::GetURLFetcher() { |
marq (ping after 24h)
2014/06/16 17:23:34
I think you can tighten things up a bit and roll t
bengr
2014/06/17 03:42:09
This is the way it is to make testing easier.
|
+ return GetBaseURLFetcher(params_->probe_url(), |
+ net::LOAD_DISABLE_CACHE | net::LOAD_BYPASS_PROXY); |
+} |
+ |
+ |
void DataReductionProxySettings::ProbeWhetherDataReductionProxyIsAvailable() { |
net::URLFetcher* fetcher = GetURLFetcher(); |
if (!fetcher) |
@@ -603,4 +622,17 @@ void DataReductionProxySettings::ProbeWhetherDataReductionProxyIsAvailable() { |
fetcher_->Start(); |
} |
+net::URLFetcher* DataReductionProxySettings::GetURLFetcherForWarmup() { |
+ return GetBaseURLFetcher(params_->warmup_url(), |
+ net::LOAD_DISABLE_CACHE); |
marq (ping after 24h)
2014/06/16 17:23:35
This will fit on one line.
bengr
2014/06/17 03:42:09
Done.
|
+} |
+ |
+void DataReductionProxySettings::WarmProxyConnection() { |
+ net::URLFetcher* fetcher = GetURLFetcherForWarmup(); |
+ if (!fetcher) |
+ return; |
+ warmup_fetcher_.reset(fetcher); |
+ warmup_fetcher_->Start(); |
+} |
+ |
} // namespace data_reduction_proxy |