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

Unified Diff: components/domain_reliability/monitor.cc

Issue 2627523003: Observe network changes from network thread in DomainReliabilityMonitor. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/domain_reliability/monitor.cc
diff --git a/components/domain_reliability/monitor.cc b/components/domain_reliability/monitor.cc
index 9c56882ecb4de1e6571e6e0b5eaf97cf999215c3..d5a437fba0997fa631b63a2c60fc26958dafedb7 100644
--- a/components/domain_reliability/monitor.cc
+++ b/components/domain_reliability/monitor.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
@@ -90,7 +91,6 @@ DomainReliabilityMonitor::DomainReliabilityMonitor(
discard_uploads_set_(false),
weak_factory_(this) {
DCHECK(OnPrefThread());
- net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
}
DomainReliabilityMonitor::DomainReliabilityMonitor(
@@ -110,22 +110,25 @@ DomainReliabilityMonitor::DomainReliabilityMonitor(
discard_uploads_set_(false),
weak_factory_(this) {
DCHECK(OnPrefThread());
- net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
}
DomainReliabilityMonitor::~DomainReliabilityMonitor() {
- if (moved_to_network_thread_)
+ if (moved_to_network_thread_) {
+ net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
DCHECK(OnNetworkThread());
- else
+ } else {
DCHECK(OnPrefThread());
-
- net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
+ }
}
void DomainReliabilityMonitor::MoveToNetworkThread() {
DCHECK(OnPrefThread());
DCHECK(!moved_to_network_thread_);
+ network_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&net::NetworkChangeNotifier::AddNetworkChangeObserver,
+ base::Unretained(this)));
moved_to_network_thread_ = true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698