Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1084)

Unified Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc

Issue 893003002: Data Reduction Proxy class ownership updates and Settings cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)));

Powered by Google App Engine
This is Rietveld 408576698