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

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: 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 prefs::kDataReductionProxyAltEnabled, 114 prefs::kDataReductionProxyAltEnabled,
115 GetOriginalProfilePrefs(), 115 GetOriginalProfilePrefs(),
116 base::Bind( 116 base::Bind(
117 &DataReductionProxySettings::OnProxyAlternativeEnabledPrefChange, 117 &DataReductionProxySettings::OnProxyAlternativeEnabledPrefChange,
118 base::Unretained(this))); 118 base::Unretained(this)));
119 } 119 }
120 120
121 void DataReductionProxySettings::InitDataReductionProxySettings( 121 void DataReductionProxySettings::InitDataReductionProxySettings(
122 PrefService* prefs, 122 PrefService* prefs,
123 PrefService* local_state_prefs, 123 PrefService* local_state_prefs,
124 net::URLRequestContextGetter* url_request_context_getter) { 124 net::URLRequestContextGetter* url_request_context_getter,
125 const base::Callback<void(bool)>& on_data_reduction_proxy_enabled) {
125 DCHECK(thread_checker_.CalledOnValidThread()); 126 DCHECK(thread_checker_.CalledOnValidThread());
126 DCHECK(prefs); 127 DCHECK(prefs);
127 DCHECK(local_state_prefs); 128 DCHECK(local_state_prefs);
128 DCHECK(url_request_context_getter); 129 DCHECK(url_request_context_getter);
129 prefs_ = prefs; 130 prefs_ = prefs;
130 local_state_prefs_ = local_state_prefs; 131 local_state_prefs_ = local_state_prefs;
131 url_request_context_getter_ = url_request_context_getter; 132 url_request_context_getter_ = url_request_context_getter;
133 on_data_reduction_proxy_enabled_ = on_data_reduction_proxy_enabled;
132 InitPrefMembers(); 134 InitPrefMembers();
133 RecordDataReductionInit(); 135 RecordDataReductionInit();
136
137 on_data_reduction_proxy_enabled_.Run(
138 IsDataReductionProxyEnabled() ? true : false);
Alexei Svitkine (slow) 2014/07/30 17:27:04 I don't think you need the ternary operator here -
megjablon 2014/07/30 18:50:48 Facepalm. Done.
139
134 // Disable the proxy if it is not allowed to be used. 140 // Disable the proxy if it is not allowed to be used.
135 if (!params_->allowed()) 141 if (!params_->allowed())
136 return; 142 return;
137 143
138 AddDefaultProxyBypassRules(); 144 AddDefaultProxyBypassRules();
139 net::NetworkChangeNotifier::AddIPAddressObserver(this); 145 net::NetworkChangeNotifier::AddIPAddressObserver(this);
140 146
141 // We set or reset the proxy pref at startup. 147 // We set or reset the proxy pref at startup.
142 MaybeActivateDataReductionProxy(true); 148 MaybeActivateDataReductionProxy(true);
143 } 149 }
144 150
145 void DataReductionProxySettings::InitDataReductionProxySettings( 151 void DataReductionProxySettings::InitDataReductionProxySettings(
146 PrefService* prefs, 152 PrefService* prefs,
147 PrefService* local_state_prefs, 153 PrefService* local_state_prefs,
148 net::URLRequestContextGetter* url_request_context_getter, 154 net::URLRequestContextGetter* url_request_context_getter,
149 scoped_ptr<DataReductionProxyConfigurator> configurator) { 155 scoped_ptr<DataReductionProxyConfigurator> configurator,
156 const base::Callback<void(bool)>& on_data_reduction_proxy_enabled) {
150 InitDataReductionProxySettings(prefs, 157 InitDataReductionProxySettings(prefs,
151 local_state_prefs, 158 local_state_prefs,
152 url_request_context_getter); 159 url_request_context_getter,
160 on_data_reduction_proxy_enabled);
153 SetProxyConfigurator(configurator.Pass()); 161 SetProxyConfigurator(configurator.Pass());
154 } 162 }
155 163
156 void DataReductionProxySettings::SetProxyConfigurator( 164 void DataReductionProxySettings::SetProxyConfigurator(
157 scoped_ptr<DataReductionProxyConfigurator> configurator) { 165 scoped_ptr<DataReductionProxyConfigurator> configurator) {
158 DCHECK(configurator); 166 DCHECK(configurator);
159 configurator_ = configurator.Pass(); 167 configurator_ = configurator.Pass();
160 } 168 }
161 169
162 bool DataReductionProxySettings::IsDataReductionProxyEnabled() { 170 bool DataReductionProxySettings::IsDataReductionProxyEnabled() {
(...skipping 10 matching lines...) Expand all
173 } 181 }
174 182
175 void DataReductionProxySettings::SetDataReductionProxyEnabled(bool enabled) { 183 void DataReductionProxySettings::SetDataReductionProxyEnabled(bool enabled) {
176 DCHECK(thread_checker_.CalledOnValidThread()); 184 DCHECK(thread_checker_.CalledOnValidThread());
177 // Prevent configuring the proxy when it is not allowed to be used. 185 // Prevent configuring the proxy when it is not allowed to be used.
178 if (!params_->allowed()) 186 if (!params_->allowed())
179 return; 187 return;
180 188
181 if (spdy_proxy_auth_enabled_.GetValue() != enabled) { 189 if (spdy_proxy_auth_enabled_.GetValue() != enabled) {
182 spdy_proxy_auth_enabled_.SetValue(enabled); 190 spdy_proxy_auth_enabled_.SetValue(enabled);
191 on_data_reduction_proxy_enabled_.Run(
192 IsDataReductionProxyEnabled() ? true : false);
Alexei Svitkine (slow) 2014/07/30 17:27:04 Ditto.
megjablon 2014/07/30 18:50:48 Done.
183 OnProxyEnabledPrefChange(); 193 OnProxyEnabledPrefChange();
184 } 194 }
185 } 195 }
186 196
187 void DataReductionProxySettings::SetDataReductionProxyAlternativeEnabled( 197 void DataReductionProxySettings::SetDataReductionProxyAlternativeEnabled(
188 bool enabled) { 198 bool enabled) {
189 DCHECK(thread_checker_.CalledOnValidThread()); 199 DCHECK(thread_checker_.CalledOnValidThread());
190 // Prevent configuring the proxy when it is not allowed to be used. 200 // Prevent configuring the proxy when it is not allowed to be used.
191 if (!params_->alternative_allowed()) 201 if (!params_->alternative_allowed())
192 return; 202 return;
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 SetProxyConfigs(enabled_by_user_, 613 SetProxyConfigs(enabled_by_user_,
604 IsDataReductionProxyAlternativeEnabled(), 614 IsDataReductionProxyAlternativeEnabled(),
605 restricted_by_carrier_, 615 restricted_by_carrier_,
606 false); 616 false);
607 } 617 }
608 disabled_on_vpn_ = false; 618 disabled_on_vpn_ = false;
609 return false; 619 return false;
610 } 620 }
611 621
612 } // namespace data_reduction_proxy 622 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698