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

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

Issue 896713003: Revert of DataReductionProxyStatisticsPrefs should support WeakPtr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_network_delegate.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc
index 8f14bd62219b48a72ce61a4990c7ecb96c05d9ff..b925211fcc7b63feed1c0ec9865e9c9fd6e31694 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc
@@ -5,7 +5,6 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h"
#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/single_thread_task_runner.h"
@@ -85,6 +84,7 @@
data_reduction_proxy_params_(params),
data_reduction_proxy_usage_stats_(NULL),
data_reduction_proxy_auth_request_handler_(handler),
+ data_reduction_proxy_statistics_prefs_(NULL),
configurator_(configurator) {
DCHECK(data_reduction_proxy_params_);
DCHECK(data_reduction_proxy_auth_request_handler_);
@@ -95,9 +95,10 @@
void DataReductionProxyNetworkDelegate::InitStatisticsPrefsAndUMA(
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
- const base::WeakPtr<DataReductionProxyStatisticsPrefs>& statistics_prefs,
+ DataReductionProxyStatisticsPrefs* statistics_prefs,
BooleanPrefMember* data_reduction_proxy_enabled,
DataReductionProxyUsageStats* usage_stats) {
+ DCHECK(statistics_prefs);
DCHECK(data_reduction_proxy_enabled);
DCHECK(usage_stats);
ui_task_runner_ = ui_task_runner;
@@ -232,47 +233,19 @@
DataReductionProxyRequestType request_type) {
DCHECK_GE(received_content_length, 0);
DCHECK_GE(original_content_length, 0);
- if (data_reduction_proxy_enabled_) {
+ if (data_reduction_proxy_enabled_ &&
+ data_reduction_proxy_statistics_prefs_) {
ui_task_runner_->PostTask(
FROM_HERE,
- base::Bind(&DataReductionProxyNetworkDelegate::UpdateContentLengthPrefs,
- base::Unretained(this),
+ base::Bind(&UpdateContentLengthPrefs,
received_content_length,
original_content_length,
data_reduction_proxy_enabled_->GetValue(),
- request_type));
+ request_type,
+ data_reduction_proxy_statistics_prefs_));
}
received_content_length_ += received_content_length;
original_content_length_ += original_content_length;
-}
-
-void DataReductionProxyNetworkDelegate::UpdateContentLengthPrefs(
- int received_content_length,
- int original_content_length,
- bool data_reduction_proxy_enabled,
- DataReductionProxyRequestType request_type) {
- if (data_reduction_proxy_statistics_prefs_) {
- int64 total_received = data_reduction_proxy_statistics_prefs_->GetInt64(
- data_reduction_proxy::prefs::kHttpReceivedContentLength);
- int64 total_original = data_reduction_proxy_statistics_prefs_->GetInt64(
- data_reduction_proxy::prefs::kHttpOriginalContentLength);
- total_received += received_content_length;
- total_original += original_content_length;
- data_reduction_proxy_statistics_prefs_->SetInt64(
- data_reduction_proxy::prefs::kHttpReceivedContentLength,
- total_received);
- data_reduction_proxy_statistics_prefs_->SetInt64(
- data_reduction_proxy::prefs::kHttpOriginalContentLength,
- total_original);
-
- UpdateContentLengthPrefsForDataReductionProxy(
- received_content_length,
- original_content_length,
- data_reduction_proxy_enabled,
- request_type,
- base::Time::Now(),
- data_reduction_proxy_statistics_prefs_.get());
- }
}
void OnResolveProxyHandler(const GURL& url,

Powered by Google App Engine
This is Rietveld 408576698