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

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

Issue 1054363002: Update DataReductionProxyNetworkDelegate/BypassStats to post tasks safely. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bengr CR comments Created 5 years, 8 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_bypass_stats.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc
index bef98bf0bea26a075368a4912ea803f8f0d0669a..e56e5701527fdf8532d9159976467df4c6ff65cc 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.cc
@@ -4,12 +4,10 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h"
-#include "base/bind.h"
#include "base/callback.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_config.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_tamper_detection.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
@@ -104,28 +102,24 @@ void DataReductionProxyBypassStats::DetectAndRecordMissingViaHeaderResponseCode(
DataReductionProxyBypassStats::DataReductionProxyBypassStats(
DataReductionProxyConfig* config,
- UnreachableCallback unreachable_callback,
- const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner)
+ UnreachableCallback unreachable_callback)
: data_reduction_proxy_config_(config),
unreachable_callback_(unreachable_callback),
last_bypass_type_(BYPASS_EVENT_TYPE_MAX),
triggering_request_(true),
- ui_task_runner_(ui_task_runner),
successful_requests_through_proxy_count_(0),
proxy_net_errors_count_(0),
unavailable_(false) {
DCHECK(config);
NetworkChangeNotifier::AddNetworkChangeObserver(this);
-};
+}
DataReductionProxyBypassStats::~DataReductionProxyBypassStats() {
NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
-};
+}
void DataReductionProxyBypassStats::OnUrlRequestCompleted(
const net::URLRequest* request, bool started) {
- DCHECK(thread_checker_.CalledOnValidThread());
-
DataReductionProxyTypeInfo proxy_info;
// Ignore requests that did not use the data reduction proxy. The check for
// LOAD_BYPASS_PROXY is necessary because the proxy_server() in the |request|
@@ -358,12 +352,10 @@ void DataReductionProxyBypassStats::RecordMissingViaHeaderBytes(
void DataReductionProxyBypassStats::OnNetworkChanged(
NetworkChangeNotifier::ConnectionType type) {
- DCHECK(thread_checker_.CalledOnValidThread());
ClearRequestCounts();
}
void DataReductionProxyBypassStats::ClearRequestCounts() {
- DCHECK(thread_checker_.CalledOnValidThread());
successful_requests_through_proxy_count_ = 0;
proxy_net_errors_count_ = 0;
}
@@ -374,18 +366,8 @@ void DataReductionProxyBypassStats::NotifyUnavailabilityIfChanged() {
(proxy_net_errors_count_ >= kMinFailedRequestsWhenUnavailable &&
successful_requests_through_proxy_count_ <=
kMaxSuccessfulRequestsWhenUnavailable);
- if (prev_unavailable != unavailable_) {
- ui_task_runner_->PostTask(FROM_HERE, base::Bind(
- &DataReductionProxyBypassStats::NotifyUnavailabilityOnUIThread,
- base::Unretained(this),
- unavailable_));
- }
-}
-
-void DataReductionProxyBypassStats::NotifyUnavailabilityOnUIThread(
- bool unavailable) {
- DCHECK(ui_task_runner_->BelongsToCurrentThread());
- unreachable_callback_.Run(unavailable);
+ if (prev_unavailable != unavailable_)
+ unreachable_callback_.Run(unavailable_);
}
void DataReductionProxyBypassStats::RecordBypassedBytes(

Powered by Google App Engine
This is Rietveld 408576698