| 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/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 13 #include "base/prefs/scoped_user_pref_update.h" | 14 #include "base/prefs/scoped_user_pref_update.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 18 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
| 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" | 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" |
| 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
| 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" | 25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" |
| 25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 26 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
| 27 #include "components/data_reduction_proxy/core/browser/data_store.h" |
| 26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 28 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 27 #include "components/proxy_config/proxy_prefs.h" | 29 #include "components/proxy_config/proxy_prefs.h" |
| 28 #include "net/base/host_port_pair.h" | 30 #include "net/base/host_port_pair.h" |
| 29 #include "net/proxy/proxy_config.h" | 31 #include "net/proxy/proxy_config.h" |
| 30 #include "net/proxy/proxy_list.h" | 32 #include "net/proxy/proxy_list.h" |
| 31 #include "net/proxy/proxy_server.h" | 33 #include "net/proxy/proxy_server.h" |
| 32 #include "net/url_request/url_request_context_getter.h" | 34 #include "net/url_request/url_request_context_getter.h" |
| 33 | 35 |
| 34 namespace { | 36 namespace { |
| 35 | 37 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 171 } |
| 170 | 172 |
| 171 void DataReductionProxyChromeSettings::Shutdown() { | 173 void DataReductionProxyChromeSettings::Shutdown() { |
| 172 data_reduction_proxy_service()->Shutdown(); | 174 data_reduction_proxy_service()->Shutdown(); |
| 173 } | 175 } |
| 174 | 176 |
| 175 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( | 177 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( |
| 176 data_reduction_proxy::DataReductionProxyIOData* io_data, | 178 data_reduction_proxy::DataReductionProxyIOData* io_data, |
| 177 PrefService* profile_prefs, | 179 PrefService* profile_prefs, |
| 178 net::URLRequestContextGetter* request_context_getter, | 180 net::URLRequestContextGetter* request_context_getter, |
| 179 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { | 181 scoped_ptr<data_reduction_proxy::DataStore> store, |
| 182 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
| 183 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner) { |
| 180 #if defined(OS_ANDROID) || defined(OS_IOS) | 184 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 181 // On mobile we write Data Reduction Proxy prefs directly to the pref service. | 185 // On mobile we write Data Reduction Proxy prefs directly to the pref service. |
| 182 // On desktop we store Data Reduction Proxy prefs in memory, writing to disk | 186 // On desktop we store Data Reduction Proxy prefs in memory, writing to disk |
| 183 // every 60 minutes and on termination. Shutdown hooks must be added for | 187 // every 60 minutes and on termination. Shutdown hooks must be added for |
| 184 // Android and iOS in order for non-zero delays to be supported. | 188 // Android and iOS in order for non-zero delays to be supported. |
| 185 // (http://crbug.com/408264) | 189 // (http://crbug.com/408264) |
| 186 base::TimeDelta commit_delay = base::TimeDelta(); | 190 base::TimeDelta commit_delay = base::TimeDelta(); |
| 187 #else | 191 #else |
| 188 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 192 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
| 189 #endif | 193 #endif |
| 190 | 194 |
| 191 scoped_ptr<data_reduction_proxy::DataReductionProxyCompressionStats> | 195 scoped_ptr<data_reduction_proxy::DataReductionProxyCompressionStats> |
| 192 compression_stats = make_scoped_ptr( | 196 compression_stats( |
| 193 new data_reduction_proxy::DataReductionProxyCompressionStats( | 197 new data_reduction_proxy::DataReductionProxyCompressionStats( |
| 194 profile_prefs, ui_task_runner, commit_delay)); | 198 profile_prefs, ui_task_runner, commit_delay)); |
| 195 scoped_ptr<data_reduction_proxy::DataReductionProxyService> service = | 199 scoped_ptr<data_reduction_proxy::DataReductionProxyService> service = |
| 196 make_scoped_ptr(new data_reduction_proxy::DataReductionProxyService( | 200 make_scoped_ptr(new data_reduction_proxy::DataReductionProxyService( |
| 197 compression_stats.Pass(), this, profile_prefs, request_context_getter, | 201 compression_stats.Pass(), this, profile_prefs, request_context_getter, |
| 198 io_data->io_task_runner())); | 202 store.Pass(), io_data->io_task_runner(), db_task_runner)); |
| 199 data_reduction_proxy::DataReductionProxySettings:: | 203 data_reduction_proxy::DataReductionProxySettings:: |
| 200 InitDataReductionProxySettings(profile_prefs, io_data, service.Pass()); | 204 InitDataReductionProxySettings(profile_prefs, io_data, service.Pass()); |
| 201 io_data->SetDataReductionProxyService( | 205 io_data->SetDataReductionProxyService( |
| 202 data_reduction_proxy_service()->GetWeakPtr()); | 206 data_reduction_proxy_service()->GetWeakPtr()); |
| 203 | 207 |
| 204 data_reduction_proxy::DataReductionProxySettings:: | 208 data_reduction_proxy::DataReductionProxySettings:: |
| 205 SetCallbackToRegisterSyntheticFieldTrial( | 209 SetCallbackToRegisterSyntheticFieldTrial( |
| 206 base::Bind( | 210 base::Bind( |
| 207 &ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial)); | 211 &ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial)); |
| 208 // TODO(bengr): Remove after M46. See http://crbug.com/445599. | 212 // TODO(bengr): Remove after M46. See http://crbug.com/445599. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 228 #elif defined(OS_OPENBSD) | 232 #elif defined(OS_OPENBSD) |
| 229 return data_reduction_proxy::Client::CHROME_OPENBSD; | 233 return data_reduction_proxy::Client::CHROME_OPENBSD; |
| 230 #elif defined(OS_SOLARIS) | 234 #elif defined(OS_SOLARIS) |
| 231 return data_reduction_proxy::Client::CHROME_SOLARIS; | 235 return data_reduction_proxy::Client::CHROME_SOLARIS; |
| 232 #elif defined(OS_QNX) | 236 #elif defined(OS_QNX) |
| 233 return data_reduction_proxy::Client::CHROME_QNX; | 237 return data_reduction_proxy::Client::CHROME_QNX; |
| 234 #else | 238 #else |
| 235 return data_reduction_proxy::Client::UNKNOWN; | 239 return data_reduction_proxy::Client::UNKNOWN; |
| 236 #endif | 240 #endif |
| 237 } | 241 } |
| OLD | NEW |