 Chromium Code Reviews
 Chromium Code Reviews Issue 2541843003:
  arc: Reduce logspam when ARC is not enabled/available  (Closed)
    
  
    Issue 2541843003:
  arc: Reduce logspam when ARC is not enabled/available  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "components/arc/net/arc_net_host_impl.h" | 5 #include "components/arc/net/arc_net_host_impl.h" | 
| 6 | 6 | 
| 7 #include <string> | 7 #include <string> | 
| 8 #include <utility> | 8 #include <utility> | 
| 9 #include <vector> | 9 #include <vector> | 
| 10 | 10 | 
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 LOG(ERROR) << "Failed to query default logical network"; | 286 LOG(ERROR) << "Failed to query default logical network"; | 
| 287 } | 287 } | 
| 288 | 288 | 
| 289 } // namespace | 289 } // namespace | 
| 290 | 290 | 
| 291 namespace arc { | 291 namespace arc { | 
| 292 | 292 | 
| 293 ArcNetHostImpl::ArcNetHostImpl(ArcBridgeService* bridge_service) | 293 ArcNetHostImpl::ArcNetHostImpl(ArcBridgeService* bridge_service) | 
| 294 : ArcService(bridge_service), binding_(this), weak_factory_(this) { | 294 : ArcService(bridge_service), binding_(this), weak_factory_(this) { | 
| 295 arc_bridge_service()->net()->AddObserver(this); | 295 arc_bridge_service()->net()->AddObserver(this); | 
| 296 GetStateHandler()->AddObserver(this, FROM_HERE); | |
| 297 } | 296 } | 
| 298 | 297 | 
| 299 ArcNetHostImpl::~ArcNetHostImpl() { | 298 ArcNetHostImpl::~ArcNetHostImpl() { | 
| 300 DCHECK(thread_checker_.CalledOnValidThread()); | 299 DCHECK(thread_checker_.CalledOnValidThread()); | 
| 301 arc_bridge_service()->net()->RemoveObserver(this); | 300 arc_bridge_service()->net()->RemoveObserver(this); | 
| 302 if (chromeos::NetworkHandler::IsInitialized()) { | 301 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.
 | |
| 303 GetStateHandler()->RemoveObserver(this, FROM_HERE); | 302 GetStateHandler()->RemoveObserver(this, FROM_HERE); | 
| 304 } | 303 } | 
| 305 } | 304 } | 
| 306 | 305 | 
| 307 void ArcNetHostImpl::OnInstanceReady() { | 306 void ArcNetHostImpl::OnInstanceReady() { | 
| 308 DCHECK(thread_checker_.CalledOnValidThread()); | 307 DCHECK(thread_checker_.CalledOnValidThread()); | 
| 309 | 308 | 
| 310 mojom::NetHostPtr host; | 309 mojom::NetHostPtr host; | 
| 311 binding_.Bind(GetProxy(&host)); | 310 binding_.Bind(GetProxy(&host)); | 
| 312 auto* instance = arc_bridge_service()->net()->GetInstanceForMethod("Init"); | 311 auto* instance = arc_bridge_service()->net()->GetInstanceForMethod("Init"); | 
| 313 DCHECK(instance); | 312 DCHECK(instance); | 
| 314 instance->Init(std::move(host)); | 313 instance->Init(std::move(host)); | 
| 314 | |
| 315 if (chromeos::NetworkHandler::IsInitialized()) { | |
| 316 GetStateHandler()->AddObserver(this, FROM_HERE); | |
| 317 observing_network_state_ = true; | |
| 318 } | |
| 319 } | |
| 320 | |
| 321 void ArcNetHostImpl::OnInstanceClosed() { | |
| 322 if (!observing_network_state_) | |
| 
Yusuke Sato
2016/11/30 23:29:39
same
 | |
| 323 return; | |
| 324 | |
| 325 GetStateHandler()->RemoveObserver(this, FROM_HERE); | |
| 326 observing_network_state_ = false; | |
| 315 } | 327 } | 
| 316 | 328 | 
| 317 void ArcNetHostImpl::GetNetworksDeprecated( | 329 void ArcNetHostImpl::GetNetworksDeprecated( | 
| 318 bool configured_only, | 330 bool configured_only, | 
| 319 bool visible_only, | 331 bool visible_only, | 
| 320 const GetNetworksDeprecatedCallback& callback) { | 332 const GetNetworksDeprecatedCallback& callback) { | 
| 321 DCHECK(thread_checker_.CalledOnValidThread()); | 333 DCHECK(thread_checker_.CalledOnValidThread()); | 
| 322 if (configured_only && visible_only) { | 334 if (configured_only && visible_only) { | 
| 323 VLOG(1) << "Illegal arguments - both configured and visible networks " | 335 VLOG(1) << "Illegal arguments - both configured and visible networks " | 
| 324 "requested."; | 336 "requested."; | 
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 "WifiEnabledStateChanged", kWifiEnabledStateChanged); | 652 "WifiEnabledStateChanged", kWifiEnabledStateChanged); | 
| 641 if (!net_instance) | 653 if (!net_instance) | 
| 642 return; | 654 return; | 
| 643 | 655 | 
| 644 bool is_enabled = GetStateHandler()->IsTechnologyEnabled( | 656 bool is_enabled = GetStateHandler()->IsTechnologyEnabled( | 
| 645 chromeos::NetworkTypePattern::WiFi()); | 657 chromeos::NetworkTypePattern::WiFi()); | 
| 646 net_instance->WifiEnabledStateChanged(is_enabled); | 658 net_instance->WifiEnabledStateChanged(is_enabled); | 
| 647 } | 659 } | 
| 648 | 660 | 
| 649 void ArcNetHostImpl::OnShuttingDown() { | 661 void ArcNetHostImpl::OnShuttingDown() { | 
| 662 DCHECK(observing_network_state_); | |
| 
Yusuke Sato
2016/11/30 23:29:39
same
 | |
| 650 GetStateHandler()->RemoveObserver(this, FROM_HERE); | 663 GetStateHandler()->RemoveObserver(this, FROM_HERE); | 
| 664 observing_network_state_ = false; | |
| 651 } | 665 } | 
| 652 | 666 | 
| 653 } // namespace arc | 667 } // namespace arc | 
| OLD | NEW |