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

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

Issue 778463002: Wrapped data reduction proxy initialization into its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@network-delegate
Patch Set: Addressed comments from sclittle Created 5 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h"
6
7 #include "base/bind.h"
8 #include "base/time/time.h"
9 #include "chrome/browser/net/chrome_net_log.h"
10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
12 #include "chrome/browser/prefs/pref_service_syncable.h"
13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.h"
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h"
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat istics_prefs.h"
16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event _store.h"
17
18 namespace content {
19 class BrowserContext;
20 }
21
22 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
23 CreateDataReductionProxyChromeIOData(
24 ChromeNetLog* net_log,
25 content::BrowserContext* browser_context,
26 PrefServiceSyncable* prefs,
27 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
28 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
29 data_reduction_proxy::DataReductionProxyConfigurator** configurator) {
30 DCHECK(net_log);
31 DCHECK(prefs);
32 DCHECK(browser_context);
33 DataReductionProxyChromeSettings* settings =
34 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
35 browser_context);
36
37 #if defined(OS_ANDROID) || defined(OS_IOS)
38 // On mobile we write data reduction proxy prefs directly to the pref service.
39 // On desktop we store data reduction proxy prefs in memory, writing to disk
40 // every 60 minutes and on termination. Shutdown hooks must be added for
41 // Android and iOS in order for non-zero delays to be supported.
42 // (http://crbug.com/408264)
43 base::TimeDelta commit_delay = base::TimeDelta();
44 #else
45 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60);
46 #endif
47
48 data_reduction_proxy::DataReductionProxyStatisticsPrefs*
49 data_reduction_proxy_statistics_prefs =
50 new data_reduction_proxy::DataReductionProxyStatisticsPrefs(
51 prefs, ui_task_runner,
52 commit_delay);
53
54 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
55 data_reduction_proxy_io_data(
56 new data_reduction_proxy::DataReductionProxyIOData(
57 DataReductionProxyChromeSettings::GetClient(),
58 settings->params()->Clone(),
59 make_scoped_ptr(data_reduction_proxy_statistics_prefs),
60 settings,
61 net_log,
62 io_task_runner,
63 ui_task_runner));
64 settings->SetDataReductionProxyStatisticsPrefs(
65 data_reduction_proxy_statistics_prefs);
66
67 // The configurator is used by DataReductionProxyChromeSettings and
68 // ProfileIOData. Ownership is passed to the latter via ProfileIOData::Handle,
69 // which is only destroyed after BrowserContextKeyedServices,
70 // including DataReductionProxyChromeSettings.
71 // Retain a raw pointer to use for initialization of data reduction proxy
72 // settings after ownership is passed.
73 *configurator = data_reduction_proxy_io_data->configurator();
74 return data_reduction_proxy_io_data.Pass();
75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698