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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/posix/eintr_wrapper.h" | 12 #include "base/posix/eintr_wrapper.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "chromeos/network/network_handler.h" | 15 #include "chromeos/network/network_handler.h" |
16 #include "chromeos/network/network_state_handler.h" | 16 #include "chromeos/network/network_state_handler.h" |
17 #include "chromeos/network/network_type_pattern.h" | |
17 #include "chromeos/network/network_util.h" | 18 #include "chromeos/network/network_util.h" |
18 #include "chromeos/network/onc/onc_utils.h" | 19 #include "chromeos/network/onc/onc_utils.h" |
19 #include "components/arc/arc_bridge_service.h" | 20 #include "components/arc/arc_bridge_service.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 const int kGetNetworksListLimit = 100; | 24 const int kGetNetworksListLimit = 100; |
24 | 25 |
25 } // namespace | 26 } // namespace |
26 | 27 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 data->networks.push_back(std::move(wc)); | 134 data->networks.push_back(std::move(wc)); |
134 } | 135 } |
135 | 136 |
136 callback.Run(std::move(data)); | 137 callback.Run(std::move(data)); |
137 } | 138 } |
138 | 139 |
139 void ArcNetHostImpl::GetWifiEnabledState( | 140 void ArcNetHostImpl::GetWifiEnabledState( |
140 const GetWifiEnabledStateCallback& callback) { | 141 const GetWifiEnabledStateCallback& callback) { |
141 bool is_enabled = GetStateHandler()->IsTechnologyEnabled( | 142 bool is_enabled = GetStateHandler()->IsTechnologyEnabled( |
142 chromeos::NetworkTypePattern::WiFi()); | 143 chromeos::NetworkTypePattern::WiFi()); |
144 callback.Run(is_enabled); | |
145 } | |
143 | 146 |
144 callback.Run(is_enabled); | 147 void ArcNetHostImpl::SetWifiEnabledState( |
148 bool is_enabled, | |
149 const SetWifiEnabledStateCallback& callback) { | |
150 DCHECK(thread_checker_.CalledOnValidThread()); | |
151 GetStateHandler()->SetTechnologyEnabled( | |
152 chromeos::NetworkTypePattern::WiFi(), is_enabled, | |
153 chromeos::network_handler::ErrorCallback()); | |
dcheng
2016/03/15 23:19:43
Out of curiosity... how are you supposed to know i
stevenjb
2016/03/15 23:31:31
There's an email thread discussing this. Right now
| |
154 callback.Run(); | |
145 } | 155 } |
146 | 156 |
147 void ArcNetHostImpl::StartScan() { | 157 void ArcNetHostImpl::StartScan() { |
148 GetStateHandler()->RequestScan(); | 158 GetStateHandler()->RequestScan(); |
149 } | 159 } |
150 | 160 |
151 void ArcNetHostImpl::ScanCompleted(const chromeos::DeviceState* /*unused*/) { | 161 void ArcNetHostImpl::ScanCompleted(const chromeos::DeviceState* /*unused*/) { |
152 if (arc_bridge_service()->net_version() < 1) { | 162 if (arc_bridge_service()->net_version() < 1) { |
153 VLOG(1) << "ArcBridgeService does not support ScanCompleted."; | 163 VLOG(1) << "ArcBridgeService does not support ScanCompleted."; |
154 return; | 164 return; |
155 } | 165 } |
156 | 166 |
157 arc_bridge_service()->net_instance()->ScanCompleted(); | 167 arc_bridge_service()->net_instance()->ScanCompleted(); |
158 } | 168 } |
159 | 169 |
160 void ArcNetHostImpl::OnShuttingDown() { | 170 void ArcNetHostImpl::OnShuttingDown() { |
161 GetStateHandler()->RemoveObserver(this, FROM_HERE); | 171 GetStateHandler()->RemoveObserver(this, FROM_HERE); |
162 } | 172 } |
163 | 173 |
164 } // namespace arc | 174 } // namespace arc |
OLD | NEW |