| OLD | NEW |
| 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 "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/prefs/pref_service.h" |
| 7 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 10 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 9 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.
h" | 11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.
h" |
| 10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura
tor.h" | 14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura
tor.h" |
| 13 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
| 14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" | 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
| 17 #include "net/url_request/url_request_context_getter.h" |
| 15 | 18 |
| 16 using data_reduction_proxy::DataReductionProxyParams; | 19 using data_reduction_proxy::DataReductionProxyParams; |
| 17 using data_reduction_proxy::DataReductionProxySettings; | 20 using data_reduction_proxy::DataReductionProxySettings; |
| 18 | 21 |
| 19 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings( | 22 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings( |
| 20 DataReductionProxyParams* params) : DataReductionProxySettings(params) { | 23 DataReductionProxyParams* params) : DataReductionProxySettings(params) { |
| 21 } | 24 } |
| 22 | 25 |
| 23 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { | 26 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { |
| 24 } | 27 } |
| 25 | 28 |
| 26 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( | 29 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( |
| 27 Profile* profile) { | 30 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> |
| 28 DCHECK(profile); | 31 configurator, |
| 29 PrefService* prefs = profile->GetPrefs(); | 32 PrefService* profile_prefs, |
| 30 | 33 PrefService* local_state_prefs, |
| 31 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> | 34 net::URLRequestContextGetter* request_context) { |
| 32 configurator(new DataReductionProxyChromeConfigurator(prefs)); | |
| 33 SetProxyConfigurator(configurator.Pass()); | 35 SetProxyConfigurator(configurator.Pass()); |
| 34 DataReductionProxySettings::InitDataReductionProxySettings( | 36 DataReductionProxySettings::InitDataReductionProxySettings( |
| 35 prefs, | 37 profile_prefs, |
| 36 g_browser_process->local_state(), | 38 local_state_prefs, |
| 37 ProfileManager::GetActiveUserProfile()->GetRequestContext()); | 39 request_context); |
| 38 DataReductionProxySettings::SetOnDataReductionEnabledCallback( | 40 DataReductionProxySettings::SetOnDataReductionEnabledCallback( |
| 39 base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, | 41 base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, |
| 40 base::Unretained(this))); | 42 base::Unretained(this))); |
| 41 | |
| 42 SetDataReductionProxyAlternativeEnabled( | 43 SetDataReductionProxyAlternativeEnabled( |
| 43 DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()); | 44 DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()); |
| 44 } | 45 } |
| 45 | 46 |
| 46 void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial( | 47 void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial( |
| 47 bool data_reduction_proxy_enabled) { | 48 bool data_reduction_proxy_enabled) { |
| 48 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( | 49 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( |
| 49 "DataReductionProxyEnabled", | 50 "DataReductionProxyEnabled", |
| 50 data_reduction_proxy_enabled ? "true" : "false"); | 51 data_reduction_proxy_enabled ? "true" : "false"); |
| 51 } | 52 } |
| OLD | NEW |