OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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/prefs/pref_service.h" |
| 9 #include "base/time/time.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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" |
| 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
| 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" |
| 15 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event
_store.h" |
| 16 |
| 17 namespace content { |
| 18 class BrowserContext; |
| 19 } |
| 20 |
| 21 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> |
| 22 CreateDataReductionProxyChromeIOData( |
| 23 net::NetLog* net_log, |
| 24 content::BrowserContext* browser_context, |
| 25 PrefService* prefs, |
| 26 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 27 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { |
| 28 DCHECK(net_log); |
| 29 DCHECK(prefs); |
| 30 DCHECK(browser_context); |
| 31 DataReductionProxyChromeSettings* settings = |
| 32 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 33 browser_context); |
| 34 |
| 35 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 36 // On mobile we write data reduction proxy prefs directly to the pref service. |
| 37 // On desktop we store data reduction proxy prefs in memory, writing to disk |
| 38 // every 60 minutes and on termination. Shutdown hooks must be added for |
| 39 // Android and iOS in order for non-zero delays to be supported. |
| 40 // (http://crbug.com/408264) |
| 41 base::TimeDelta commit_delay = base::TimeDelta(); |
| 42 #else |
| 43 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
| 44 #endif |
| 45 |
| 46 data_reduction_proxy::DataReductionProxyStatisticsPrefs* |
| 47 data_reduction_proxy_statistics_prefs = |
| 48 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( |
| 49 prefs, ui_task_runner, |
| 50 commit_delay); |
| 51 |
| 52 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> |
| 53 data_reduction_proxy_io_data( |
| 54 new data_reduction_proxy::DataReductionProxyIOData( |
| 55 DataReductionProxyChromeSettings::GetClient(), |
| 56 make_scoped_ptr(data_reduction_proxy_statistics_prefs), |
| 57 settings, |
| 58 net_log, |
| 59 io_task_runner, |
| 60 ui_task_runner)); |
| 61 data_reduction_proxy_io_data->InitOnUIThread(prefs); |
| 62 settings->SetDataReductionProxyStatisticsPrefs( |
| 63 data_reduction_proxy_statistics_prefs); |
| 64 |
| 65 return data_reduction_proxy_io_data.Pass(); |
| 66 } |
OLD | NEW |