Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
|
sclittle
2015/01/14 22:54:46
nit: add '#include "content/public/browser/browser
bengr
2015/01/15 00:30:31
I forward declared it.
sclittle
2015/01/15 02:18:56
Actually, you don't need to forward declare it her
| |
| 18 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> | |
| 19 CreateDataReductionProxyChromeIOData( | |
| 20 ChromeNetLog* net_log, | |
| 21 content::BrowserContext* browser_context, | |
| 22 PrefServiceSyncable* prefs, | |
| 23 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | |
| 24 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, | |
| 25 data_reduction_proxy::DataReductionProxyConfigurator** configurator) { | |
| 26 DCHECK(net_log); | |
| 27 DCHECK(prefs); | |
| 28 DCHECK(browser_context); | |
| 29 DataReductionProxyChromeSettings* settings = | |
| 30 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | |
| 31 browser_context); | |
| 32 | |
| 33 #if defined(OS_ANDROID) || defined(OS_IOS) | |
| 34 // On mobile we write data reduction proxy prefs directly to the pref service. | |
| 35 // On desktop we store data reduction proxy prefs in memory, writing to disk | |
| 36 // every 60 minutes and on termination. Shutdown hooks must be added for | |
| 37 // Android and iOS in order for non-zero delays to be supported. | |
| 38 // (http://crbug.com/408264) | |
| 39 base::TimeDelta commit_delay = base::TimeDelta(); | |
| 40 #else | |
| 41 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | |
| 42 #endif | |
| 43 | |
| 44 data_reduction_proxy::DataReductionProxyStatisticsPrefs* | |
| 45 data_reduction_proxy_statistics_prefs = | |
| 46 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( | |
| 47 prefs, ui_task_runner, | |
| 48 commit_delay); | |
| 49 | |
| 50 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> | |
| 51 data_reduction_proxy_io_data( | |
| 52 new data_reduction_proxy::DataReductionProxyIOData( | |
| 53 DataReductionProxyChromeSettings::GetClient(), | |
| 54 settings->params()->Clone(), | |
| 55 make_scoped_ptr(data_reduction_proxy_statistics_prefs), | |
| 56 settings, | |
| 57 net_log, | |
| 58 io_task_runner, | |
| 59 ui_task_runner)); | |
| 60 settings->SetDataReductionProxyStatisticsPrefs( | |
| 61 data_reduction_proxy_statistics_prefs); | |
| 62 | |
| 63 // The configurator is used by DataReductionProxyChromeSettings and | |
| 64 // ProfileIOData. Ownership is passed to the latter via ProfileIOData::Handle, | |
| 65 // which is only destroyed after BrowserContextKeyedServices, | |
| 66 // including DataReductionProxyChromeSettings. | |
| 67 // Retain a raw pointer to use for initialization of data reduction proxy | |
| 68 // settings after ownership is passed. | |
| 69 *configurator = data_reduction_proxy_io_data->configurator(); | |
| 70 return data_reduction_proxy_io_data.Pass(); | |
| 71 } | |
| OLD | NEW |