Chromium Code Reviews| Index: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc |
| diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..03b4bfb09cfc150eb12cf67a4ab120a3f98140c5 |
| --- /dev/null |
| +++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/time/time.h" |
| +#include "chrome/browser/net/chrome_net_log.h" |
| +#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| +#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h" |
| +#include "chrome/browser/prefs/pref_service_syncable.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" |
| +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h" |
| + |
|
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
|
| +scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> |
| +CreateDataReductionProxyChromeIOData( |
| + ChromeNetLog* net_log, |
| + content::BrowserContext* browser_context, |
| + PrefServiceSyncable* prefs, |
| + const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| + const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
| + data_reduction_proxy::DataReductionProxyConfigurator** configurator) { |
| + DCHECK(net_log); |
| + DCHECK(prefs); |
| + DCHECK(browser_context); |
| + DataReductionProxyChromeSettings* settings = |
| + DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| + browser_context); |
| + |
| +#if defined(OS_ANDROID) || defined(OS_IOS) |
| + // On mobile we write data reduction proxy prefs directly to the pref service. |
| + // On desktop we store data reduction proxy prefs in memory, writing to disk |
| + // every 60 minutes and on termination. Shutdown hooks must be added for |
| + // Android and iOS in order for non-zero delays to be supported. |
| + // (http://crbug.com/408264) |
| + base::TimeDelta commit_delay = base::TimeDelta(); |
| +#else |
| + base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
| +#endif |
| + |
| + data_reduction_proxy::DataReductionProxyStatisticsPrefs* |
| + data_reduction_proxy_statistics_prefs = |
| + new data_reduction_proxy::DataReductionProxyStatisticsPrefs( |
| + prefs, ui_task_runner, |
| + commit_delay); |
| + |
| + scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> |
| + data_reduction_proxy_io_data( |
| + new data_reduction_proxy::DataReductionProxyIOData( |
| + DataReductionProxyChromeSettings::GetClient(), |
| + settings->params()->Clone(), |
| + make_scoped_ptr(data_reduction_proxy_statistics_prefs), |
| + settings, |
| + net_log, |
| + io_task_runner, |
| + ui_task_runner)); |
| + settings->SetDataReductionProxyStatisticsPrefs( |
| + data_reduction_proxy_statistics_prefs); |
| + |
| + // The configurator is used by DataReductionProxyChromeSettings and |
| + // ProfileIOData. Ownership is passed to the latter via ProfileIOData::Handle, |
| + // which is only destroyed after BrowserContextKeyedServices, |
| + // including DataReductionProxyChromeSettings. |
| + // Retain a raw pointer to use for initialization of data reduction proxy |
| + // settings after ownership is passed. |
| + *configurator = data_reduction_proxy_io_data->configurator(); |
| + return data_reduction_proxy_io_data.Pass(); |
| +} |