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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc

Issue 388663002: Added data reduction proxy holdback experiment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 net::URLRequestContextGetter* url_request_context_getter) { 103 net::URLRequestContextGetter* url_request_context_getter) {
104 DCHECK(thread_checker_.CalledOnValidThread()); 104 DCHECK(thread_checker_.CalledOnValidThread());
105 DCHECK(prefs); 105 DCHECK(prefs);
106 DCHECK(local_state_prefs); 106 DCHECK(local_state_prefs);
107 DCHECK(url_request_context_getter); 107 DCHECK(url_request_context_getter);
108 prefs_ = prefs; 108 prefs_ = prefs;
109 local_state_prefs_ = local_state_prefs; 109 local_state_prefs_ = local_state_prefs;
110 url_request_context_getter_ = url_request_context_getter; 110 url_request_context_getter_ = url_request_context_getter;
111 InitPrefMembers(); 111 InitPrefMembers();
112 RecordDataReductionInit(); 112 RecordDataReductionInit();
113
114 // Disable the proxy if it is not allowed to be used. 113 // Disable the proxy if it is not allowed to be used.
115 if (!params_->allowed()) 114 if (!params_->allowed())
116 return; 115 return;
117 116
118 AddDefaultProxyBypassRules(); 117 AddDefaultProxyBypassRules();
119 net::NetworkChangeNotifier::AddIPAddressObserver(this); 118 net::NetworkChangeNotifier::AddIPAddressObserver(this);
120 119
121 // We set or reset the proxy pref at startup. 120 // We set or reset the proxy pref at startup.
122 MaybeActivateDataReductionProxy(true); 121 MaybeActivateDataReductionProxy(true);
123 } 122 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 bool at_startup) { 348 bool at_startup) {
350 DCHECK(thread_checker_.CalledOnValidThread()); 349 DCHECK(thread_checker_.CalledOnValidThread());
351 PrefService* prefs = GetOriginalProfilePrefs(); 350 PrefService* prefs = GetOriginalProfilePrefs();
352 // TODO(marq): Consider moving this so stats are wiped the first time the 351 // TODO(marq): Consider moving this so stats are wiped the first time the
353 // proxy settings are actually (not maybe) turned on. 352 // proxy settings are actually (not maybe) turned on.
354 if (spdy_proxy_auth_enabled_.GetValue() && 353 if (spdy_proxy_auth_enabled_.GetValue() &&
355 !prefs->GetBoolean(prefs::kDataReductionProxyWasEnabledBefore)) { 354 !prefs->GetBoolean(prefs::kDataReductionProxyWasEnabledBefore)) {
356 prefs->SetBoolean(prefs::kDataReductionProxyWasEnabledBefore, true); 355 prefs->SetBoolean(prefs::kDataReductionProxyWasEnabledBefore, true);
357 ResetDataReductionStatistics(); 356 ResetDataReductionStatistics();
358 } 357 }
359
360 // Configure use of the data reduction proxy if it is enabled. 358 // Configure use of the data reduction proxy if it is enabled.
361 enabled_by_user_= IsDataReductionProxyEnabled(); 359 enabled_by_user_= IsDataReductionProxyEnabled();
362 SetProxyConfigs(enabled_by_user_, 360 SetProxyConfigs(enabled_by_user_,
363 IsDataReductionProxyAlternativeEnabled(), 361 IsDataReductionProxyAlternativeEnabled(),
364 restricted_by_carrier_, 362 restricted_by_carrier_,
365 at_startup); 363 at_startup);
366 364
367 // Check if the proxy has been restricted explicitly by the carrier. 365 // Check if the proxy has been restricted explicitly by the carrier.
368 if (enabled_by_user_) { 366 if (enabled_by_user_) {
369 ProbeWhetherDataReductionProxyIsAvailable(); 367 ProbeWhetherDataReductionProxyIsAvailable();
370 WarmProxyConnection(); 368 WarmProxyConnection();
371 } 369 }
372 } 370 }
373 371
374 void DataReductionProxySettings::SetProxyConfigs(bool enabled, 372 void DataReductionProxySettings::SetProxyConfigs(bool enabled,
375 bool alternative_enabled, 373 bool alternative_enabled,
376 bool restricted, 374 bool restricted,
377 bool at_startup) { 375 bool at_startup) {
378 DCHECK(thread_checker_.CalledOnValidThread()); 376 DCHECK(thread_checker_.CalledOnValidThread());
379 LogProxyState(enabled, restricted, at_startup); 377 LogProxyState(enabled, restricted, at_startup);
380 // The alternative is only configured if the standard configuration is 378 // The alternative is only configured if the standard configuration is
381 // is enabled. 379 // is enabled.
382 if (enabled) { 380 if (enabled & !params_->holdback()) {
383 if (alternative_enabled) { 381 if (alternative_enabled) {
384 configurator_->Enable(restricted, 382 configurator_->Enable(restricted,
385 !params_->fallback_allowed(), 383 !params_->fallback_allowed(),
386 params_->alt_origin().spec(), 384 params_->alt_origin().spec(),
387 params_->alt_fallback_origin().spec(), 385 params_->alt_fallback_origin().spec(),
388 params_->ssl_origin().spec()); 386 params_->ssl_origin().spec());
389 } else { 387 } else {
390 configurator_->Enable(restricted, 388 configurator_->Enable(restricted,
391 !params_->fallback_allowed(), 389 !params_->fallback_allowed(),
392 params_->origin().spec(), 390 params_->origin().spec(),
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 534
537 void DataReductionProxySettings::WarmProxyConnection() { 535 void DataReductionProxySettings::WarmProxyConnection() {
538 net::URLFetcher* fetcher = GetURLFetcherForWarmup(); 536 net::URLFetcher* fetcher = GetURLFetcherForWarmup();
539 if (!fetcher) 537 if (!fetcher)
540 return; 538 return;
541 warmup_fetcher_.reset(fetcher); 539 warmup_fetcher_.reset(fetcher);
542 warmup_fetcher_->Start(); 540 warmup_fetcher_->Start();
543 } 541 }
544 542
545 } // namespace data_reduction_proxy 543 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698