| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
| 12 #include "base/time/time.h" |
| 12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 14 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 14 #include "chrome/browser/prefs/proxy_prefs.h" | 15 #include "chrome/browser/prefs/proxy_prefs.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" |
| 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
| 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" |
| 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
| 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" | 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" |
| 22 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 23 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
| 24 | 26 |
| 25 using data_reduction_proxy::Client; | 27 using data_reduction_proxy::Client; |
| 26 using data_reduction_proxy::DataReductionProxyParams; | 28 using data_reduction_proxy::DataReductionProxyParams; |
| 27 using data_reduction_proxy::DataReductionProxySettings; | 29 using data_reduction_proxy::DataReductionProxySettings; |
| 28 | 30 |
| 29 // The Data Reduction Proxy has been turned into a "best effort" proxy, | 31 // The Data Reduction Proxy has been turned into a "best effort" proxy, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 60 return; | 62 return; |
| 61 net::ProxyConfig::ProxyRules proxy_rules; | 63 net::ProxyConfig::ProxyRules proxy_rules; |
| 62 proxy_rules.ParseFromString(proxy_server); | 64 proxy_rules.ParseFromString(proxy_server); |
| 63 if (!data_reduction_proxy::DataReductionProxyConfigurator:: | 65 if (!data_reduction_proxy::DataReductionProxyConfigurator:: |
| 64 ContainsDataReductionProxy(proxy_rules)) { | 66 ContainsDataReductionProxy(proxy_rules)) { |
| 65 return; | 67 return; |
| 66 } | 68 } |
| 67 prefs->ClearPref(prefs::kProxy); | 69 prefs->ClearPref(prefs::kProxy); |
| 68 } | 70 } |
| 69 | 71 |
| 70 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings( | 72 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings() |
| 71 scoped_ptr<DataReductionProxyParams> params) | 73 : DataReductionProxySettings() { |
| 72 : DataReductionProxySettings(params.Pass()) { | |
| 73 } | 74 } |
| 74 | 75 |
| 75 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { | 76 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { |
| 76 } | 77 } |
| 77 | 78 |
| 79 void DataReductionProxyChromeSettings::Shutdown() { |
| 80 data_reduction_proxy_service()->Shutdown(); |
| 81 } |
| 82 |
| 78 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( | 83 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( |
| 79 data_reduction_proxy::DataReductionProxyIOData* io_data, | 84 data_reduction_proxy::DataReductionProxyIOData* io_data, |
| 80 PrefService* profile_prefs, | 85 PrefService* profile_prefs, |
| 81 PrefService* local_state_prefs, | 86 net::URLRequestContextGetter* request_context_getter, |
| 82 net::URLRequestContextGetter* request_context, | 87 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { |
| 83 bool enable_quic) { | 88 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 84 SetProxyConfigurator(io_data->configurator()); | 89 // On mobile we write Data Reduction Proxy prefs directly to the pref service. |
| 90 // On desktop we store Data Reduction Proxy prefs in memory, writing to disk |
| 91 // every 60 minutes and on termination. Shutdown hooks must be added for |
| 92 // Android and iOS in order for non-zero delays to be supported. |
| 93 // (http://crbug.com/408264) |
| 94 base::TimeDelta commit_delay = base::TimeDelta(); |
| 95 #else |
| 96 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
| 97 #endif |
| 98 |
| 99 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs> |
| 100 statistics_prefs = make_scoped_ptr( |
| 101 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( |
| 102 profile_prefs, ui_task_runner, commit_delay)); |
| 103 scoped_ptr<data_reduction_proxy::DataReductionProxyService> |
| 104 service = make_scoped_ptr( |
| 105 new data_reduction_proxy::DataReductionProxyService( |
| 106 statistics_prefs.Pass(), this, request_context_getter)); |
| 85 DataReductionProxySettings::InitDataReductionProxySettings( | 107 DataReductionProxySettings::InitDataReductionProxySettings( |
| 86 profile_prefs, | 108 profile_prefs, io_data, service.Pass()); |
| 87 io_data->PassStatisticsPrefs(), | 109 io_data->SetDataReductionProxyService( |
| 88 request_context, | 110 data_reduction_proxy_service()->GetWeakPtr()); |
| 89 io_data->net_log(), | 111 |
| 90 io_data->event_store(), | |
| 91 enable_quic); | |
| 92 DataReductionProxySettings::SetOnDataReductionEnabledCallback( | 112 DataReductionProxySettings::SetOnDataReductionEnabledCallback( |
| 93 base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, | 113 base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, |
| 94 base::Unretained(this))); | 114 base::Unretained(this))); |
| 95 SetDataReductionProxyAlternativeEnabled( | 115 SetDataReductionProxyAlternativeEnabled( |
| 96 DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()); | 116 DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()); |
| 97 // TODO(bengr): Remove after M46. See http://crbug.com/445599. | 117 // TODO(bengr): Remove after M46. See http://crbug.com/445599. |
| 98 MigrateDataReductionProxyOffProxyPrefs(profile_prefs); | 118 MigrateDataReductionProxyOffProxyPrefs(profile_prefs); |
| 99 } | 119 } |
| 100 | 120 |
| 101 void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial( | 121 void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 124 #elif defined(OS_OPENBSD) | 144 #elif defined(OS_OPENBSD) |
| 125 return Client::CHROME_OPENBSD; | 145 return Client::CHROME_OPENBSD; |
| 126 #elif defined(OS_SOLARIS) | 146 #elif defined(OS_SOLARIS) |
| 127 return Client::CHROME_SOLARIS; | 147 return Client::CHROME_SOLARIS; |
| 128 #elif defined(OS_QNX) | 148 #elif defined(OS_QNX) |
| 129 return Client::CHROME_QNX; | 149 return Client::CHROME_QNX; |
| 130 #else | 150 #else |
| 131 return Client::UNKNOWN; | 151 return Client::UNKNOWN; |
| 132 #endif | 152 #endif |
| 133 } | 153 } |
| OLD | NEW |