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

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

Issue 778463002: Wrapped data reduction proxy initialization into its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@network-delegate
Patch Set: Addressed comment from mmenke Created 6 years 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_usage_stats.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.cc
index a755e6de5983cddc1b8b5933a903a769ef98e271..37f1ce1df15bca5099a6deb81ecf97668a185b97 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.cc
@@ -6,10 +6,11 @@
#include "base/bind.h"
#include "base/callback.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h"
#include "base/prefs/pref_member.h"
+#include "base/single_thread_task_runner.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "net/base/load_flags.h"
@@ -102,11 +103,13 @@ void DataReductionProxyUsageStats::DetectAndRecordMissingViaHeaderResponseCode(
DataReductionProxyUsageStats::DataReductionProxyUsageStats(
DataReductionProxyParams* params,
- const scoped_refptr<MessageLoopProxy>& ui_thread_proxy)
+ DataReductionProxySettings* settings,
+ const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner)
: data_reduction_proxy_params_(params),
+ settings_(settings),
last_bypass_type_(BYPASS_EVENT_TYPE_MAX),
triggering_request_(true),
- ui_thread_proxy_(ui_thread_proxy),
+ ui_task_runner_(ui_task_runner),
successful_requests_through_proxy_count_(0),
proxy_net_errors_count_(0),
unavailable_(false) {
@@ -174,7 +177,7 @@ void DataReductionProxyUsageStats::NotifyUnavailabilityIfChanged() {
successful_requests_through_proxy_count_ <=
kMaxSuccessfulRequestsWhenUnavailable);
if (prev_unavailable != unavailable_) {
- ui_thread_proxy_->PostTask(FROM_HERE, base::Bind(
+ ui_task_runner_->PostTask(FROM_HERE, base::Bind(
&DataReductionProxyUsageStats::NotifyUnavailabilityOnUIThread,
base::Unretained(this),
unavailable_));
@@ -183,9 +186,9 @@ void DataReductionProxyUsageStats::NotifyUnavailabilityIfChanged() {
void DataReductionProxyUsageStats::NotifyUnavailabilityOnUIThread(
bool unavailable) {
- DCHECK(ui_thread_proxy_->BelongsToCurrentThread());
- if (!unavailable_callback_.is_null())
- unavailable_callback_.Run(unavailable);
+ DCHECK(ui_task_runner_->BelongsToCurrentThread());
+ if (settings_)
+ settings_->SetUnreachable(unavailable);
}
void DataReductionProxyUsageStats::SetBypassType(

Powered by Google App Engine
This is Rietveld 408576698