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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc

Issue 888713002: DataReductionProxyStatisticsPrefs should support WeakPtr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Webview fix 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: components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc
index 71d206e262ac18329d6267a954c12ac4d94040d7..c4f779f346dd8cbded06b31bd2457651aa8d8864 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc
@@ -15,6 +15,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_interceptor.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.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_reduction_proxy_usage_stats.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
@@ -31,7 +32,7 @@ DataReductionProxyIOData::DataReductionProxyIOData(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
: client_(client),
- statistics_prefs_(statistics_prefs.Pass()),
+ temporary_statistics_prefs_(statistics_prefs.Pass()),
settings_(settings),
net_log_(net_log),
io_task_runner_(io_task_runner),
@@ -50,6 +51,8 @@ DataReductionProxyIOData::DataReductionProxyIOData(
proxy_delegate_.reset(
new data_reduction_proxy::DataReductionProxyDelegate(
auth_request_handler_.get(), params_.get()));
+ if (temporary_statistics_prefs_)
+ statistics_prefs_ = temporary_statistics_prefs_->GetWeakPtr();
}
DataReductionProxyIOData::~DataReductionProxyIOData() {
@@ -62,17 +65,23 @@ void DataReductionProxyIOData::InitOnUIThread(PrefService* pref_service) {
enabled_.MoveToThread(io_task_runner_);
}
-void DataReductionProxyIOData::ShutdownOnUIThread() {
+void DataReductionProxyIOData::ShutdownOnUIThread() {
DCHECK(!shutdown_on_ui_);
DCHECK(ui_task_runner_->BelongsToCurrentThread());
- if (statistics_prefs_) {
- statistics_prefs_->WritePrefs();
- statistics_prefs_->ShutdownOnUIThread();
- }
enabled_.Destroy();
shutdown_on_ui_ = true;
}
+void DataReductionProxyIOData::SetDataReductionProxyStatisticsPrefs(
+ base::WeakPtr<DataReductionProxyStatisticsPrefs> statistics_prefs) {
+ statistics_prefs_ = statistics_prefs;
+}
+
+scoped_ptr<DataReductionProxyStatisticsPrefs>
+DataReductionProxyIOData::PassStatisticsPrefs() {
+ return temporary_statistics_prefs_.Pass();
+}
+
bool DataReductionProxyIOData::IsEnabled() const {
DCHECK(io_task_runner_->BelongsToCurrentThread());
return enabled_.GetValue() ||
@@ -87,15 +96,6 @@ DataReductionProxyIOData::CreateInterceptor() {
params_.get(), usage_stats_.get(), event_store_.get()));
}
-void DataReductionProxyIOData::EnableCompressionStatisticsLogging(
- PrefService* prefs,
- const base::TimeDelta& commit_delay) {
- DCHECK(ui_task_runner_->BelongsToCurrentThread());
- statistics_prefs_.reset(
- new DataReductionProxyStatisticsPrefs(
- prefs, ui_task_runner_, commit_delay));
-}
-
scoped_ptr<DataReductionProxyNetworkDelegate>
DataReductionProxyIOData::CreateNetworkDelegate(
scoped_ptr<net::NetworkDelegate> wrapped_network_delegate,
@@ -106,12 +106,10 @@ DataReductionProxyIOData::CreateNetworkDelegate(
wrapped_network_delegate.Pass(), params_.get(),
auth_request_handler_.get(), configurator_.get()));
if (track_proxy_bypass_statistics && !usage_stats_) {
- usage_stats_.reset(
- new data_reduction_proxy::DataReductionProxyUsageStats(
+ usage_stats_.reset(new data_reduction_proxy::DataReductionProxyUsageStats(
params_.get(), settings_, ui_task_runner_));
network_delegate->InitStatisticsPrefsAndUMA(
- ui_task_runner_, statistics_prefs_.get(), &enabled_,
- usage_stats_.get());
+ ui_task_runner_, statistics_prefs_, &enabled_, usage_stats_.get());
}
return network_delegate.Pass();
}

Powered by Google App Engine
This is Rietveld 408576698