Chromium Code Reviews| 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/chrome_net_log.h" | |
|
mmenke
2015/01/22 17:14:48
Per suggestion in other file, can get rid of this.
bengr
2015/01/23 20:09:03
Done.
| |
| 11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | |
| 12 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.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 PrefService* prefs, | |
| 27 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | |
| 28 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { | |
| 29 DCHECK(net_log); | |
| 30 DCHECK(prefs); | |
| 31 DCHECK(browser_context); | |
| 32 DataReductionProxyChromeSettings* settings = | |
| 33 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | |
| 34 browser_context); | |
| 35 | |
| 36 #if defined(OS_ANDROID) || defined(OS_IOS) | |
| 37 // On mobile we write data reduction proxy prefs directly to the pref service. | |
| 38 // On desktop we store data reduction proxy prefs in memory, writing to disk | |
| 39 // every 60 minutes and on termination. Shutdown hooks must be added for | |
| 40 // Android and iOS in order for non-zero delays to be supported. | |
| 41 // (http://crbug.com/408264) | |
|
mmenke
2015/01/22 17:14:48
Doesn't belong in this CL, but could consider a 10
bengr
2015/01/23 20:09:03
It's not clear the data loss will be small. Chrome
| |
| 42 base::TimeDelta commit_delay = base::TimeDelta(); | |
| 43 #else | |
| 44 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | |
| 45 #endif | |
| 46 | |
| 47 data_reduction_proxy::DataReductionProxyStatisticsPrefs* | |
| 48 data_reduction_proxy_statistics_prefs = | |
| 49 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( | |
| 50 prefs, ui_task_runner, | |
| 51 commit_delay); | |
| 52 | |
| 53 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> | |
| 54 data_reduction_proxy_io_data( | |
| 55 new data_reduction_proxy::DataReductionProxyIOData( | |
| 56 DataReductionProxyChromeSettings::GetClient(), | |
| 57 make_scoped_ptr(data_reduction_proxy_statistics_prefs), | |
| 58 settings, | |
| 59 net_log, | |
| 60 io_task_runner, | |
| 61 ui_task_runner)); | |
| 62 data_reduction_proxy_io_data->InitPrefsOnUIThread(prefs); | |
| 63 settings->SetDataReductionProxyStatisticsPrefs( | |
| 64 data_reduction_proxy_statistics_prefs); | |
| 65 | |
| 66 return data_reduction_proxy_io_data.Pass(); | |
| 67 } | |
| OLD | NEW |