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

Unified Diff: components/arc/net/arc_net_host_impl.cc

Issue 2553713002: [Merge M-56] arc: Reduce logspam when ARC is not enabled/available (Closed)
Patch Set: Created 4 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
« no previous file with comments | « components/arc/net/arc_net_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/net/arc_net_host_impl.cc
diff --git a/components/arc/net/arc_net_host_impl.cc b/components/arc/net/arc_net_host_impl.cc
index be17b60cc45eb144608db2a4e0ee234b53d6640a..938a824ddd54e2dee3118af9fc48a77be7451d1b 100644
--- a/components/arc/net/arc_net_host_impl.cc
+++ b/components/arc/net/arc_net_host_impl.cc
@@ -293,13 +293,12 @@ namespace arc {
ArcNetHostImpl::ArcNetHostImpl(ArcBridgeService* bridge_service)
: ArcService(bridge_service), binding_(this), weak_factory_(this) {
arc_bridge_service()->net()->AddObserver(this);
- GetStateHandler()->AddObserver(this, FROM_HERE);
}
ArcNetHostImpl::~ArcNetHostImpl() {
DCHECK(thread_checker_.CalledOnValidThread());
arc_bridge_service()->net()->RemoveObserver(this);
- if (chromeos::NetworkHandler::IsInitialized()) {
+ if (observing_network_state_) {
GetStateHandler()->RemoveObserver(this, FROM_HERE);
}
}
@@ -312,6 +311,19 @@ void ArcNetHostImpl::OnInstanceReady() {
auto* instance = arc_bridge_service()->net()->GetInstanceForMethod("Init");
DCHECK(instance);
instance->Init(std::move(host));
+
+ if (chromeos::NetworkHandler::IsInitialized()) {
+ GetStateHandler()->AddObserver(this, FROM_HERE);
+ observing_network_state_ = true;
+ }
+}
+
+void ArcNetHostImpl::OnInstanceClosed() {
+ if (!observing_network_state_)
+ return;
+
+ GetStateHandler()->RemoveObserver(this, FROM_HERE);
+ observing_network_state_ = false;
}
void ArcNetHostImpl::GetNetworksDeprecated(
@@ -647,7 +659,9 @@ void ArcNetHostImpl::DeviceListChanged() {
}
void ArcNetHostImpl::OnShuttingDown() {
+ DCHECK(observing_network_state_);
GetStateHandler()->RemoveObserver(this, FROM_HERE);
+ observing_network_state_ = false;
}
} // namespace arc
« no previous file with comments | « components/arc/net/arc_net_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698