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

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

Issue 421653005: Adding synthetic field trial for DataReductionProxyEnabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@newPltWithCL
Patch Set: Moving set callback out of init Created 6 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 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 net::URLRequestContextGetter* url_request_context_getter) { 124 net::URLRequestContextGetter* url_request_context_getter) {
125 DCHECK(thread_checker_.CalledOnValidThread()); 125 DCHECK(thread_checker_.CalledOnValidThread());
126 DCHECK(prefs); 126 DCHECK(prefs);
127 DCHECK(local_state_prefs); 127 DCHECK(local_state_prefs);
128 DCHECK(url_request_context_getter); 128 DCHECK(url_request_context_getter);
129 prefs_ = prefs; 129 prefs_ = prefs;
130 local_state_prefs_ = local_state_prefs; 130 local_state_prefs_ = local_state_prefs;
131 url_request_context_getter_ = url_request_context_getter; 131 url_request_context_getter_ = url_request_context_getter;
132 InitPrefMembers(); 132 InitPrefMembers();
133 RecordDataReductionInit(); 133 RecordDataReductionInit();
134
134 // Disable the proxy if it is not allowed to be used. 135 // Disable the proxy if it is not allowed to be used.
135 if (!params_->allowed()) 136 if (!params_->allowed())
136 return; 137 return;
137 138
138 AddDefaultProxyBypassRules(); 139 AddDefaultProxyBypassRules();
139 net::NetworkChangeNotifier::AddIPAddressObserver(this); 140 net::NetworkChangeNotifier::AddIPAddressObserver(this);
140 141
141 // We set or reset the proxy pref at startup. 142 // We set or reset the proxy pref at startup.
142 MaybeActivateDataReductionProxy(true); 143 MaybeActivateDataReductionProxy(true);
143 } 144 }
144 145
145 void DataReductionProxySettings::InitDataReductionProxySettings( 146 void DataReductionProxySettings::InitDataReductionProxySettings(
146 PrefService* prefs, 147 PrefService* prefs,
147 PrefService* local_state_prefs, 148 PrefService* local_state_prefs,
148 net::URLRequestContextGetter* url_request_context_getter, 149 net::URLRequestContextGetter* url_request_context_getter,
149 scoped_ptr<DataReductionProxyConfigurator> configurator) { 150 scoped_ptr<DataReductionProxyConfigurator> configurator) {
150 InitDataReductionProxySettings(prefs, 151 InitDataReductionProxySettings(prefs,
151 local_state_prefs, 152 local_state_prefs,
152 url_request_context_getter); 153 url_request_context_getter);
153 SetProxyConfigurator(configurator.Pass()); 154 SetProxyConfigurator(configurator.Pass());
154 } 155 }
155 156
157 void DataReductionProxySettings::SetOnDataReductionEnabledCallback(
158 const base::Callback<void(bool)>& on_data_reduction_proxy_enabled) {
159 on_data_reduction_proxy_enabled_ = on_data_reduction_proxy_enabled;
160 on_data_reduction_proxy_enabled_.Run(IsDataReductionProxyEnabled());
bengr 2014/07/30 23:42:07 Is this needed?
megjablon 2014/07/30 23:57:06 Yes, because we want the synthetic field trial set
161 }
162
156 void DataReductionProxySettings::SetProxyConfigurator( 163 void DataReductionProxySettings::SetProxyConfigurator(
157 scoped_ptr<DataReductionProxyConfigurator> configurator) { 164 scoped_ptr<DataReductionProxyConfigurator> configurator) {
158 DCHECK(configurator); 165 DCHECK(configurator);
159 configurator_ = configurator.Pass(); 166 configurator_ = configurator.Pass();
160 } 167 }
161 168
162 bool DataReductionProxySettings::IsDataReductionProxyEnabled() { 169 bool DataReductionProxySettings::IsDataReductionProxyEnabled() {
163 return spdy_proxy_auth_enabled_.GetValue() || IsEnabledOnCommandLine(); 170 return spdy_proxy_auth_enabled_.GetValue() || IsEnabledOnCommandLine();
164 } 171 }
165 172
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 RecordNetworkChangeEvent(IP_CHANGED); 358 RecordNetworkChangeEvent(IP_CHANGED);
352 if (DisableIfVPN()) 359 if (DisableIfVPN())
353 return; 360 return;
354 ProbeWhetherDataReductionProxyIsAvailable(); 361 ProbeWhetherDataReductionProxyIsAvailable();
355 WarmProxyConnection(); 362 WarmProxyConnection();
356 } 363 }
357 } 364 }
358 365
359 void DataReductionProxySettings::OnProxyEnabledPrefChange() { 366 void DataReductionProxySettings::OnProxyEnabledPrefChange() {
360 DCHECK(thread_checker_.CalledOnValidThread()); 367 DCHECK(thread_checker_.CalledOnValidThread());
368 if (!on_data_reduction_proxy_enabled_.is_null())
369 on_data_reduction_proxy_enabled_.Run(IsDataReductionProxyEnabled());
361 if (!params_->allowed()) 370 if (!params_->allowed())
362 return; 371 return;
363 MaybeActivateDataReductionProxy(false); 372 MaybeActivateDataReductionProxy(false);
364 } 373 }
365 374
366 void DataReductionProxySettings::OnProxyAlternativeEnabledPrefChange() { 375 void DataReductionProxySettings::OnProxyAlternativeEnabledPrefChange() {
367 DCHECK(thread_checker_.CalledOnValidThread()); 376 DCHECK(thread_checker_.CalledOnValidThread());
368 if (!params_->alternative_allowed()) 377 if (!params_->alternative_allowed())
369 return; 378 return;
370 MaybeActivateDataReductionProxy(false); 379 MaybeActivateDataReductionProxy(false);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 SetProxyConfigs(enabled_by_user_, 612 SetProxyConfigs(enabled_by_user_,
604 IsDataReductionProxyAlternativeEnabled(), 613 IsDataReductionProxyAlternativeEnabled(),
605 restricted_by_carrier_, 614 restricted_by_carrier_,
606 false); 615 false);
607 } 616 }
608 disabled_on_vpn_ = false; 617 disabled_on_vpn_ = false;
609 return false; 618 return false;
610 } 619 }
611 620
612 } // namespace data_reduction_proxy 621 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698