| 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 "base/time/time.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | 14 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
| 15 #include "chrome/browser/prefs/proxy_prefs.h" | 15 #include "chrome/browser/prefs/proxy_prefs.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" |
| 20 #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" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" |
| 22 #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" |
| 23 #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" |
| 24 #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" |
| 25 #include "net/url_request/url_request_context_getter.h" | |
| 26 | 25 |
| 27 // The Data Reduction Proxy has been turned into a "best effort" proxy, | 26 // The Data Reduction Proxy has been turned into a "best effort" proxy, |
| 28 // meaning it is used only if the effective proxy configuration resolves to | 27 // meaning it is used only if the effective proxy configuration resolves to |
| 29 // DIRECT for a URL. It no longer can be a ProxyConfig in the proxy preference | 28 // DIRECT for a URL. It no longer can be a ProxyConfig in the proxy preference |
| 30 // hierarchy. This method removes the Data Reduction Proxy configuration from | 29 // hierarchy. This method removes the Data Reduction Proxy configuration from |
| 31 // prefs, if present. |proxy_pref_name| is the name of the proxy pref. | 30 // prefs, if present. |proxy_pref_name| is the name of the proxy pref. |
| 32 void DataReductionProxyChromeSettings::MigrateDataReductionProxyOffProxyPrefs( | 31 void DataReductionProxyChromeSettings::MigrateDataReductionProxyOffProxyPrefs( |
| 33 PrefService* prefs) { | 32 PrefService* prefs) { |
| 34 base::DictionaryValue* dict = | 33 base::DictionaryValue* dict = |
| 35 (base::DictionaryValue*) prefs->GetUserPrefValue(prefs::kProxy); | 34 (base::DictionaryValue*) prefs->GetUserPrefValue(prefs::kProxy); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { | 70 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { |
| 72 } | 71 } |
| 73 | 72 |
| 74 void DataReductionProxyChromeSettings::Shutdown() { | 73 void DataReductionProxyChromeSettings::Shutdown() { |
| 75 data_reduction_proxy_service()->Shutdown(); | 74 data_reduction_proxy_service()->Shutdown(); |
| 76 } | 75 } |
| 77 | 76 |
| 78 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( | 77 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( |
| 79 data_reduction_proxy::DataReductionProxyIOData* io_data, | 78 data_reduction_proxy::DataReductionProxyIOData* io_data, |
| 80 PrefService* profile_prefs, | 79 PrefService* profile_prefs, |
| 81 net::URLRequestContextGetter* request_context_getter, | |
| 82 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { | 80 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { |
| 83 #if defined(OS_ANDROID) || defined(OS_IOS) | 81 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 84 // On mobile we write Data Reduction Proxy prefs directly to the pref service. | 82 // On mobile we write Data Reduction Proxy prefs directly to the pref service. |
| 85 // On desktop we store Data Reduction Proxy prefs in memory, writing to disk | 83 // On desktop we store Data Reduction Proxy prefs in memory, writing to disk |
| 86 // every 60 minutes and on termination. Shutdown hooks must be added for | 84 // every 60 minutes and on termination. Shutdown hooks must be added for |
| 87 // Android and iOS in order for non-zero delays to be supported. | 85 // Android and iOS in order for non-zero delays to be supported. |
| 88 // (http://crbug.com/408264) | 86 // (http://crbug.com/408264) |
| 89 base::TimeDelta commit_delay = base::TimeDelta(); | 87 base::TimeDelta commit_delay = base::TimeDelta(); |
| 90 #else | 88 #else |
| 91 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 89 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
| 92 #endif | 90 #endif |
| 93 | 91 |
| 94 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs> | 92 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs> |
| 95 statistics_prefs = make_scoped_ptr( | 93 statistics_prefs = make_scoped_ptr( |
| 96 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( | 94 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( |
| 97 profile_prefs, ui_task_runner, commit_delay)); | 95 profile_prefs, ui_task_runner, commit_delay)); |
| 98 scoped_ptr<data_reduction_proxy::DataReductionProxyService> | 96 scoped_ptr<data_reduction_proxy::DataReductionProxyService> |
| 99 service = make_scoped_ptr( | 97 service = make_scoped_ptr( |
| 100 new data_reduction_proxy::DataReductionProxyService( | 98 new data_reduction_proxy::DataReductionProxyService( |
| 101 statistics_prefs.Pass(), this, request_context_getter)); | 99 statistics_prefs.Pass(), this)); |
| 102 data_reduction_proxy::DataReductionProxySettings:: | 100 data_reduction_proxy::DataReductionProxySettings:: |
| 103 InitDataReductionProxySettings(profile_prefs, io_data, service.Pass()); | 101 InitDataReductionProxySettings(profile_prefs, io_data, service.Pass()); |
| 104 io_data->SetDataReductionProxyService( | 102 io_data->SetDataReductionProxyService( |
| 105 data_reduction_proxy_service()->GetWeakPtr()); | 103 data_reduction_proxy_service()->GetWeakPtr()); |
| 106 | 104 |
| 107 data_reduction_proxy::DataReductionProxySettings:: | 105 data_reduction_proxy::DataReductionProxySettings:: |
| 108 SetCallbackToRegisterSyntheticFieldTrial( | 106 SetCallbackToRegisterSyntheticFieldTrial( |
| 109 base::Bind( | 107 base::Bind( |
| 110 &ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial)); | 108 &ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial)); |
| 111 SetDataReductionProxyAlternativeEnabled( | 109 SetDataReductionProxyAlternativeEnabled( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 134 #elif defined(OS_OPENBSD) | 132 #elif defined(OS_OPENBSD) |
| 135 return data_reduction_proxy::Client::CHROME_OPENBSD; | 133 return data_reduction_proxy::Client::CHROME_OPENBSD; |
| 136 #elif defined(OS_SOLARIS) | 134 #elif defined(OS_SOLARIS) |
| 137 return data_reduction_proxy::Client::CHROME_SOLARIS; | 135 return data_reduction_proxy::Client::CHROME_SOLARIS; |
| 138 #elif defined(OS_QNX) | 136 #elif defined(OS_QNX) |
| 139 return data_reduction_proxy::Client::CHROME_QNX; | 137 return data_reduction_proxy::Client::CHROME_QNX; |
| 140 #else | 138 #else |
| 141 return data_reduction_proxy::Client::UNKNOWN; | 139 return data_reduction_proxy::Client::UNKNOWN; |
| 142 #endif | 140 #endif |
| 143 } | 141 } |
| OLD | NEW |