Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc

Issue 1173343009: LevelDB storage for data reduction proxy to store data usage stats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use raw pointers for arguments instead of ref counting Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/prefs/proxy_prefs.h" 19 #include "chrome/browser/prefs/proxy_prefs.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp ression_stats.h" 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp ression_stats.h"
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h" 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h"
24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" 25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h"
25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h" 26 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h"
26 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" 27 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h"
28 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stor e_impl.h"
27 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 29 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.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
36 // Assume that any proxy host ending with this suffix is a Data Reduction Proxy. 38 // Assume that any proxy host ending with this suffix is a Data Reduction Proxy.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 170 }
169 171
170 void DataReductionProxyChromeSettings::Shutdown() { 172 void DataReductionProxyChromeSettings::Shutdown() {
171 data_reduction_proxy_service()->Shutdown(); 173 data_reduction_proxy_service()->Shutdown();
172 } 174 }
173 175
174 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( 176 void DataReductionProxyChromeSettings::InitDataReductionProxySettings(
175 data_reduction_proxy::DataReductionProxyIOData* io_data, 177 data_reduction_proxy::DataReductionProxyIOData* io_data,
176 PrefService* profile_prefs, 178 PrefService* profile_prefs,
177 net::URLRequestContextGetter* request_context_getter, 179 net::URLRequestContextGetter* request_context_getter,
178 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { 180 const base::FilePath& profile_path,
181 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
182 const scoped_refptr<base::SingleThreadTaskRunner>& db_task_runner) {
179 #if defined(OS_ANDROID) || defined(OS_IOS) 183 #if defined(OS_ANDROID) || defined(OS_IOS)
180 // On mobile we write Data Reduction Proxy prefs directly to the pref service. 184 // On mobile we write Data Reduction Proxy prefs directly to the pref service.
181 // On desktop we store Data Reduction Proxy prefs in memory, writing to disk 185 // On desktop we store Data Reduction Proxy prefs in memory, writing to disk
182 // every 60 minutes and on termination. Shutdown hooks must be added for 186 // every 60 minutes and on termination. Shutdown hooks must be added for
183 // Android and iOS in order for non-zero delays to be supported. 187 // Android and iOS in order for non-zero delays to be supported.
184 // (http://crbug.com/408264) 188 // (http://crbug.com/408264)
185 base::TimeDelta commit_delay = base::TimeDelta(); 189 base::TimeDelta commit_delay = base::TimeDelta();
186 #else 190 #else
187 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); 191 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60);
188 #endif 192 #endif
189 193
194 scoped_refptr<data_reduction_proxy::DataReductionProxyStoreImpl> store(
bengr 2015/06/25 23:22:54 So the store is created on UI and initialzed on DB
Not at Google. Contact bengr 2015/06/29 20:53:26 UI thread outlives DB thread. For DB thread hops
195 new data_reduction_proxy::DataReductionProxyStoreImpl(profile_path));
196 db_task_runner->PostTask(
197 FROM_HERE, base::Bind(&data_reduction_proxy::DataReductionProxyStoreImpl::
198 InitializeOnDBThread,
199 store));
200
190 scoped_ptr<data_reduction_proxy::DataReductionProxyCompressionStats> 201 scoped_ptr<data_reduction_proxy::DataReductionProxyCompressionStats>
191 compression_stats = make_scoped_ptr( 202 compression_stats(
192 new data_reduction_proxy::DataReductionProxyCompressionStats( 203 new data_reduction_proxy::DataReductionProxyCompressionStats(
193 profile_prefs, ui_task_runner, commit_delay)); 204 profile_prefs, ui_task_runner, db_task_runner, store,
205 commit_delay));
194 scoped_ptr<data_reduction_proxy::DataReductionProxyService> service = 206 scoped_ptr<data_reduction_proxy::DataReductionProxyService> service =
195 make_scoped_ptr(new data_reduction_proxy::DataReductionProxyService( 207 make_scoped_ptr(new data_reduction_proxy::DataReductionProxyService(
196 compression_stats.Pass(), this, profile_prefs, request_context_getter, 208 compression_stats.Pass(), this, profile_prefs, request_context_getter,
197 io_data->io_task_runner())); 209 io_data->io_task_runner()));
198 data_reduction_proxy::DataReductionProxySettings:: 210 data_reduction_proxy::DataReductionProxySettings::
michaeln 2015/06/26 20:15:00 Lots of symbols in this method are prefixed with d
Not at Google. Contact bengr 2015/06/29 20:53:26 The data_reduction_proxy code has actively moved a
199 InitDataReductionProxySettings(profile_prefs, io_data, service.Pass()); 211 InitDataReductionProxySettings(profile_prefs, io_data, service.Pass());
200 io_data->SetDataReductionProxyService( 212 io_data->SetDataReductionProxyService(
201 data_reduction_proxy_service()->GetWeakPtr()); 213 data_reduction_proxy_service()->GetWeakPtr());
202 214
203 data_reduction_proxy::DataReductionProxySettings:: 215 data_reduction_proxy::DataReductionProxySettings::
204 SetCallbackToRegisterSyntheticFieldTrial( 216 SetCallbackToRegisterSyntheticFieldTrial(
205 base::Bind( 217 base::Bind(
206 &ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial)); 218 &ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial));
207 SetDataReductionProxyAlternativeEnabled( 219 SetDataReductionProxyAlternativeEnabled(
208 data_reduction_proxy::params::IsIncludedInAlternativeFieldTrial()); 220 data_reduction_proxy::params::IsIncludedInAlternativeFieldTrial());
(...skipping 20 matching lines...) Expand all
229 #elif defined(OS_OPENBSD) 241 #elif defined(OS_OPENBSD)
230 return data_reduction_proxy::Client::CHROME_OPENBSD; 242 return data_reduction_proxy::Client::CHROME_OPENBSD;
231 #elif defined(OS_SOLARIS) 243 #elif defined(OS_SOLARIS)
232 return data_reduction_proxy::Client::CHROME_SOLARIS; 244 return data_reduction_proxy::Client::CHROME_SOLARIS;
233 #elif defined(OS_QNX) 245 #elif defined(OS_QNX)
234 return data_reduction_proxy::Client::CHROME_QNX; 246 return data_reduction_proxy::Client::CHROME_QNX;
235 #else 247 #else
236 return data_reduction_proxy::Client::UNKNOWN; 248 return data_reduction_proxy::Client::UNKNOWN;
237 #endif 249 #endif
238 } 250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698