Index: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc |
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc |
index 761c2d3297ad3289557ee52928c60428673334d6..e73873fcea8bed70a69a35b921d6e195e747a2c8 100644 |
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc |
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc |
@@ -7,6 +7,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/prefs/pref_service.h" |
#include "base/prefs/scoped_user_pref_update.h" |
+#include "base/time/time.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h" |
#include "chrome/browser/prefs/proxy_prefs.h" |
@@ -17,6 +18,7 @@ |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h" |
+#include "components/data_reduction_proxy/core/browser/data_saver_service.h" |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" |
#include "net/url_request/url_request_context_getter.h" |
@@ -58,26 +60,44 @@ void MigrateDataReductionProxyOffProxyPrefs(PrefService* prefs) { |
prefs->ClearPref(prefs::kProxy); |
} |
-DataReductionProxyChromeSettings::DataReductionProxyChromeSettings( |
- scoped_ptr<DataReductionProxyParams> params) |
- : DataReductionProxySettings(params.Pass()) { |
+DataReductionProxyChromeSettings::DataReductionProxyChromeSettings() |
+ : DataReductionProxySettings() { |
} |
DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { |
} |
+void DataReductionProxyChromeSettings::Shutdown() { |
+ SaverService()->Shutdown(); |
+} |
+ |
void DataReductionProxyChromeSettings::InitDataReductionProxySettings( |
data_reduction_proxy::DataReductionProxyIOData* io_data, |
PrefService* profile_prefs, |
- PrefService* local_state_prefs, |
- net::URLRequestContextGetter* request_context) { |
- SetProxyConfigurator(io_data->configurator()); |
+ net::URLRequestContextGetter* request_context, |
+ const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { |
+#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 |
+ |
+ scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs> |
+ statistics_prefs = make_scoped_ptr( |
+ new data_reduction_proxy::DataReductionProxyStatisticsPrefs( |
+ profile_prefs, ui_task_runner, commit_delay)); |
+ scoped_ptr<data_reduction_proxy::DataSaverService> data_saver_service = |
+ make_scoped_ptr(new data_reduction_proxy::DataSaverService( |
+ statistics_prefs.Pass(), this, request_context)); |
DataReductionProxySettings::InitDataReductionProxySettings( |
- profile_prefs, |
- io_data->PassStatisticsPrefs(), |
- request_context, |
- io_data->net_log(), |
- io_data->event_store()); |
+ profile_prefs, io_data, data_saver_service.Pass()); |
+ io_data->SetDataSaverService(SaverService()->GetWeakPtr()); |
+ |
DataReductionProxySettings::SetOnDataReductionEnabledCallback( |
base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, |
base::Unretained(this))); |