Chromium Code Reviews| 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 09caeb9c66c59b912175ddb08bfb8731a2972c43..22ca5abae2b5551caa8ea502e3820642f6d3d068 100644 |
| --- a/components/arc/net/arc_net_host_impl.cc |
| +++ b/components/arc/net/arc_net_host_impl.cc |
| @@ -27,7 +27,10 @@ |
| namespace { |
| -const int kGetNetworksListLimit = 100; |
| +constexpr int kGetNetworksListLimit = 100; |
| +constexpr uint32_t kDefaultMinInstanceVersion = 0; |
| +constexpr uint32_t kDefaultNetworkChangedMinInstanceVersion = 2; |
| +constexpr uint32_t kWifiEnabledStateChanged = 3; |
| chromeos::NetworkStateHandler* GetStateHandler() { |
| return chromeos::NetworkHandler::Get()->network_state_handler(); |
| @@ -572,16 +575,12 @@ void ArcNetHostImpl::StartScan() { |
| } |
| void ArcNetHostImpl::ScanCompleted(const chromeos::DeviceState* /*unused*/) { |
| - if (!arc_bridge_service()->net()->instance()) { |
| - VLOG(2) << "NetInstance not ready yet"; |
| + auto* net_instance = arc_bridge_service()->net()->GetInstanceForVersion( |
| + kDefaultMinInstanceVersion, "ScanCompleted"); |
|
Yusuke Sato
2016/09/17 01:38:57
nit: ScanCompleted has [MinVersion=1] but version
Luis Héctor Chávez
2016/09/17 01:56:11
Done.
|
| + if (!net_instance) |
| return; |
| - } |
| - if (arc_bridge_service()->net()->version() < 1) { |
| - VLOG(1) << "NetInstance does not support ScanCompleted."; |
| - return; |
| - } |
| - arc_bridge_service()->net()->instance()->ScanCompleted(); |
| + net_instance->ScanCompleted(); |
| } |
| void ArcNetHostImpl::GetDefaultNetwork( |
| @@ -605,29 +604,28 @@ void ArcNetHostImpl::GetDefaultNetwork( |
| void ArcNetHostImpl::DefaultNetworkSuccessCallback( |
| const std::string& service_path, |
| const base::DictionaryValue& dictionary) { |
| - if (!arc_bridge_service()->net()->instance()) { |
| - VLOG(2) << "NetInstance is null."; |
| + auto* net_instance = arc_bridge_service()->net()->GetInstanceForVersion( |
| + kDefaultMinInstanceVersion, "DefaultNetworkChanged"); |
|
Yusuke Sato
2016/09/17 01:38:57
Ok, then could you document why kDefaultMinInstanc
Luis Héctor Chávez
2016/09/17 01:56:11
Oh there was a bug here! This should have been kDe
|
| + if (!net_instance) |
| return; |
| - } |
| - arc_bridge_service()->net()->instance()->DefaultNetworkChanged( |
| - TranslateONCConfiguration(&dictionary), |
| - TranslateONCConfiguration(&dictionary)); |
| + |
| + net_instance->DefaultNetworkChanged(TranslateONCConfiguration(&dictionary), |
| + TranslateONCConfiguration(&dictionary)); |
| } |
| void ArcNetHostImpl::DefaultNetworkChanged( |
| const chromeos::NetworkState* network) { |
| - if (arc_bridge_service()->net()->version() < 2) { |
| - VLOG(1) << "ArcBridgeService does not support DefaultNetworkChanged."; |
| - return; |
| - } |
| - |
| if (!network) { |
| VLOG(1) << "No default network"; |
| - arc_bridge_service()->net()->instance()->DefaultNetworkChanged(nullptr, |
| - nullptr); |
| + net_instance->DefaultNetworkChanged(nullptr, nullptr); |
|
Yusuke Sato
2016/09/17 01:38:57
nit: this won't compile :)
I meant something like
Luis Héctor Chávez
2016/09/17 01:56:11
Yeah, realized this too late :P Done.
|
| return; |
| } |
| + auto* net_instance = arc_bridge_service()->net()->GetInstanceForVersion( |
| + kDefaultNetworkChangedMinInstanceVersion, "DefaultNetworkChanged"); |
|
Yusuke Sato
2016/09/17 01:38:57
..and then, why this one was okay to use kDefaultN
Luis Héctor Chávez
2016/09/17 01:56:11
Both should use it.
|
| + if (!net_instance) |
| + return; |
| + |
| VLOG(1) << "New default network: " << network->path(); |
| std::string user_id_hash = chromeos::LoginState::Get()->primary_user_hash(); |
| GetManagedConfigurationHandler()->GetProperties( |
| @@ -638,14 +636,14 @@ void ArcNetHostImpl::DefaultNetworkChanged( |
| } |
| void ArcNetHostImpl::DeviceListChanged() { |
| - if (arc_bridge_service()->net()->version() < 3) { |
| - VLOG(1) << "ArcBridgeService does not support DeviceListChanged."; |
| + auto* net_instance = arc_bridge_service()->net()->GetInstanceForVersion( |
| + kWifiEnabledStateChanged, "WifiEnabledStateChanged"); |
| + if (!net_instance) |
| return; |
| - } |
| bool is_enabled = GetStateHandler()->IsTechnologyEnabled( |
| chromeos::NetworkTypePattern::WiFi()); |
| - arc_bridge_service()->net()->instance()->WifiEnabledStateChanged(is_enabled); |
| + net_instance->WifiEnabledStateChanged(is_enabled); |
| } |
| void ArcNetHostImpl::OnShuttingDown() { |