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

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

Issue 2541843003: 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
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_) {
Yusuke Sato 2016/11/30 23:29:39 Do we need the check? I think the convention in Ch
Luis Héctor Chávez 2016/11/30 23:45:08 Yes, but https://cs.chromium.org/chromium/src/chro
Yusuke Sato 2016/11/30 23:59:30 Acknowledged.
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_)
Yusuke Sato 2016/11/30 23:29:39 same
+ 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_);
Yusuke Sato 2016/11/30 23:29:39 same
GetStateHandler()->RemoveObserver(this, FROM_HERE);
+ observing_network_state_ = false;
}
} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698