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_comp
ression_stats.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" | 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" |
21 #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_io_d
ata.h" |
22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv
ice.h" |
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.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::DataReductionProxyCompressionStats> | 92 scoped_ptr<data_reduction_proxy::DataReductionProxyCompressionStats> |
95 compression_stats = make_scoped_ptr( | 93 compression_stats = make_scoped_ptr( |
96 new data_reduction_proxy::DataReductionProxyCompressionStats( | 94 new data_reduction_proxy::DataReductionProxyCompressionStats( |
97 profile_prefs, ui_task_runner, commit_delay)); | 95 profile_prefs, ui_task_runner, commit_delay)); |
98 scoped_ptr<data_reduction_proxy::DataReductionProxyService> service = | 96 scoped_ptr<data_reduction_proxy::DataReductionProxyService> service = |
99 make_scoped_ptr(new data_reduction_proxy::DataReductionProxyService( | 97 make_scoped_ptr(new data_reduction_proxy::DataReductionProxyService( |
100 compression_stats.Pass(), this, request_context_getter)); | 98 compression_stats.Pass(), this)); |
101 data_reduction_proxy::DataReductionProxySettings:: | 99 data_reduction_proxy::DataReductionProxySettings:: |
102 InitDataReductionProxySettings(profile_prefs, io_data, service.Pass()); | 100 InitDataReductionProxySettings(profile_prefs, io_data, service.Pass()); |
103 io_data->SetDataReductionProxyService( | 101 io_data->SetDataReductionProxyService( |
104 data_reduction_proxy_service()->GetWeakPtr()); | 102 data_reduction_proxy_service()->GetWeakPtr()); |
105 | 103 |
106 data_reduction_proxy::DataReductionProxySettings:: | 104 data_reduction_proxy::DataReductionProxySettings:: |
107 SetCallbackToRegisterSyntheticFieldTrial( | 105 SetCallbackToRegisterSyntheticFieldTrial( |
108 base::Bind( | 106 base::Bind( |
109 &ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial)); | 107 &ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial)); |
110 SetDataReductionProxyAlternativeEnabled( | 108 SetDataReductionProxyAlternativeEnabled( |
(...skipping 22 matching lines...) Expand all Loading... |
133 #elif defined(OS_OPENBSD) | 131 #elif defined(OS_OPENBSD) |
134 return data_reduction_proxy::Client::CHROME_OPENBSD; | 132 return data_reduction_proxy::Client::CHROME_OPENBSD; |
135 #elif defined(OS_SOLARIS) | 133 #elif defined(OS_SOLARIS) |
136 return data_reduction_proxy::Client::CHROME_SOLARIS; | 134 return data_reduction_proxy::Client::CHROME_SOLARIS; |
137 #elif defined(OS_QNX) | 135 #elif defined(OS_QNX) |
138 return data_reduction_proxy::Client::CHROME_QNX; | 136 return data_reduction_proxy::Client::CHROME_QNX; |
139 #else | 137 #else |
140 return data_reduction_proxy::Client::UNKNOWN; | 138 return data_reduction_proxy::Client::UNKNOWN; |
141 #endif | 139 #endif |
142 } | 140 } |
OLD | NEW |