Chromium Code Reviews| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 } | 45 } |
| 46 | 46 |
| 47 void ArcNetHostImpl::OnNetInstanceReady() { | 47 void ArcNetHostImpl::OnNetInstanceReady() { |
| 48 DCHECK(thread_checker_.CalledOnValidThread()); | 48 DCHECK(thread_checker_.CalledOnValidThread()); |
| 49 | 49 |
| 50 NetHostPtr host; | 50 NetHostPtr host; |
| 51 binding_.Bind(GetProxy(&host)); | 51 binding_.Bind(GetProxy(&host)); |
| 52 arc_bridge_service()->net_instance()->Init(std::move(host)); | 52 arc_bridge_service()->net_instance()->Init(std::move(host)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ArcNetHostImpl::GetNetworks(bool configured_only, | 55 void ArcNetHostImpl::GetNetworksDeprecated( |
| 56 bool visible_only, | 56 bool configured_only, |
| 57 bool visible_only, | |
| 58 const GetNetworksDeprecatedCallback& callback) { | |
| 59 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 60 if (configured_only && visible_only) { | |
| 61 VLOG(1) << "Illegal arguments - both configured and visible networks " | |
| 62 "requested."; | |
| 63 return; | |
| 64 } | |
| 65 | |
| 66 GetNetworksRequestType type = GetNetworksRequestType::CONFIGURED_ONLY; | |
| 67 if (visible_only) { | |
| 68 type = GetNetworksRequestType::VISIBLE_ONLY; | |
| 69 } | |
| 70 | |
| 71 GetNetworks(type, callback); | |
| 72 } | |
| 73 | |
| 74 void ArcNetHostImpl::GetNetworks(GetNetworksRequestType type, | |
| 57 const GetNetworksCallback& callback) { | 75 const GetNetworksCallback& callback) { |
| 76 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 77 | |
| 58 NetworkDataPtr data = NetworkData::New(); | 78 NetworkDataPtr data = NetworkData::New(); |
| 59 data->status = NetworkResult::SUCCESS; | 79 bool configured_only = true; |
| 80 bool visible_only = false; | |
| 81 if (type == GetNetworksRequestType::VISIBLE_ONLY) { | |
| 82 configured_only = false; | |
| 83 visible_only = true; | |
| 84 } | |
|
dcheng
2016/03/03 05:56:20
It might be slightly shorter to just write:
bool
| |
| 60 | 85 |
| 61 // Retrieve list of nearby wifi networks | 86 // Retrieve list of nearby wifi networks |
| 62 chromeos::NetworkTypePattern network_pattern = | 87 chromeos::NetworkTypePattern network_pattern = |
| 63 chromeos::onc::NetworkTypePatternFromOncType(onc::network_type::kWiFi); | 88 chromeos::onc::NetworkTypePatternFromOncType(onc::network_type::kWiFi); |
| 64 scoped_ptr<base::ListValue> network_properties_list = | 89 scoped_ptr<base::ListValue> network_properties_list = |
| 65 chromeos::network_util::TranslateNetworkListToONC( | 90 chromeos::network_util::TranslateNetworkListToONC( |
| 66 network_pattern, configured_only, visible_only, | 91 network_pattern, configured_only, visible_only, |
| 67 kGetNetworksListLimit); | 92 kGetNetworksListLimit); |
| 68 | 93 |
| 69 // Extract info for each network and add it to the list. | 94 // Extract info for each network and add it to the list. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 } | 150 } |
| 126 | 151 |
| 127 arc_bridge_service()->net_instance()->ScanCompleted(); | 152 arc_bridge_service()->net_instance()->ScanCompleted(); |
| 128 } | 153 } |
| 129 | 154 |
| 130 void ArcNetHostImpl::OnShuttingDown() { | 155 void ArcNetHostImpl::OnShuttingDown() { |
| 131 GetStateHandler()->RemoveObserver(this, FROM_HERE); | 156 GetStateHandler()->RemoveObserver(this, FROM_HERE); |
| 132 } | 157 } |
| 133 | 158 |
| 134 } // namespace arc | 159 } // namespace arc |
| OLD | NEW |