OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdio.h> | 5 #include <stdio.h> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 } | 127 } |
128 | 128 |
129 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
130 if (parsed_command_line.HasSwitch("debug")) | 130 if (parsed_command_line.HasSwitch("debug")) |
131 MessageBoxA(NULL, __FUNCTION__, "Debug Me!", MB_OK); | 131 MessageBoxA(NULL, __FUNCTION__, "Debug Me!", MB_OK); |
132 #endif | 132 #endif |
133 | 133 |
134 base::MessageLoopForIO loop; | 134 base::MessageLoopForIO loop; |
135 | 135 |
136 wifi_service_.reset(WiFiService::Create()); | 136 wifi_service_.reset(WiFiService::Create()); |
137 wifi_service_->Initialize(loop.message_loop_proxy()); | 137 wifi_service_->Initialize(loop.task_runner()); |
138 | 138 |
139 if (parsed_command_line.HasSwitch("list")) { | 139 if (parsed_command_line.HasSwitch("list")) { |
140 base::ListValue network_list; | 140 base::ListValue network_list; |
141 wifi_service_->GetVisibleNetworks(std::string(), &network_list, true); | 141 wifi_service_->GetVisibleNetworks(std::string(), &network_list, true); |
142 VLOG(0) << network_list; | 142 VLOG(0) << network_list; |
143 return true; | 143 return true; |
144 } | 144 } |
145 | 145 |
146 if (parsed_command_line.HasSwitch("get_properties")) { | 146 if (parsed_command_line.HasSwitch("get_properties")) { |
147 if (network_guid.length() > 0) { | 147 if (network_guid.length() > 0) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 if (parsed_command_line.HasSwitch("connect")) { | 186 if (parsed_command_line.HasSwitch("connect")) { |
187 if (!network_guid.empty()) { | 187 if (!network_guid.empty()) { |
188 std::string error; | 188 std::string error; |
189 if (!properties->empty()) { | 189 if (!properties->empty()) { |
190 VLOG(0) << "Using connect properties: " << *properties; | 190 VLOG(0) << "Using connect properties: " << *properties; |
191 wifi_service_->SetProperties(network_guid, properties.Pass(), &error); | 191 wifi_service_->SetProperties(network_guid, properties.Pass(), &error); |
192 } | 192 } |
193 | 193 |
194 wifi_service_->SetEventObservers( | 194 wifi_service_->SetEventObservers( |
195 loop.message_loop_proxy(), | 195 loop.task_runner(), |
196 base::Bind(&WiFiTest::OnNetworksChanged, base::Unretained(this)), | 196 base::Bind(&WiFiTest::OnNetworksChanged, base::Unretained(this)), |
197 base::Bind(&WiFiTest::OnNetworkListChanged, base::Unretained(this))); | 197 base::Bind(&WiFiTest::OnNetworkListChanged, base::Unretained(this))); |
198 | 198 |
199 wifi_service_->StartConnect(network_guid, &error); | 199 wifi_service_->StartConnect(network_guid, &error); |
200 VLOG(0) << error; | 200 VLOG(0) << error; |
201 if (error.empty()) | 201 if (error.empty()) |
202 base::MessageLoop::current()->Run(); | 202 base::MessageLoop::current()->Run(); |
203 return true; | 203 return true; |
204 } | 204 } |
205 } | 205 } |
(...skipping 12 matching lines...) Expand all Loading... |
218 std::string error; | 218 std::string error; |
219 std::string key_data; | 219 std::string key_data; |
220 wifi_service_->GetKeyFromSystem(network_guid, &key_data, &error); | 220 wifi_service_->GetKeyFromSystem(network_guid, &key_data, &error); |
221 VLOG(0) << key_data << error; | 221 VLOG(0) << key_data << error; |
222 return true; | 222 return true; |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 if (parsed_command_line.HasSwitch("scan")) { | 226 if (parsed_command_line.HasSwitch("scan")) { |
227 wifi_service_->SetEventObservers( | 227 wifi_service_->SetEventObservers( |
228 loop.message_loop_proxy(), | 228 loop.task_runner(), |
229 base::Bind(&WiFiTest::OnNetworksChanged, base::Unretained(this)), | 229 base::Bind(&WiFiTest::OnNetworksChanged, base::Unretained(this)), |
230 base::Bind(&WiFiTest::OnNetworkListChanged, base::Unretained(this))); | 230 base::Bind(&WiFiTest::OnNetworkListChanged, base::Unretained(this))); |
231 wifi_service_->RequestNetworkScan(); | 231 wifi_service_->RequestNetworkScan(); |
232 base::MessageLoop::current()->Run(); | 232 base::MessageLoop::current()->Run(); |
233 return true; | 233 return true; |
234 } | 234 } |
235 | 235 |
236 if (parsed_command_line.HasSwitch("get_connected_ssid")) { | 236 if (parsed_command_line.HasSwitch("get_connected_ssid")) { |
237 std::string ssid; | 237 std::string ssid; |
238 std::string error; | 238 std::string error; |
(...skipping 12 matching lines...) Expand all Loading... |
251 | 251 |
252 int main(int argc, const char* argv[]) { | 252 int main(int argc, const char* argv[]) { |
253 base::CommandLine::Init(argc, argv); | 253 base::CommandLine::Init(argc, argv); |
254 logging::LoggingSettings settings; | 254 logging::LoggingSettings settings; |
255 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 255 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
256 logging::InitLogging(settings); | 256 logging::InitLogging(settings); |
257 | 257 |
258 wifi::WiFiTest wifi_test; | 258 wifi::WiFiTest wifi_test; |
259 return wifi_test.Main(argc, argv); | 259 return wifi_test.Main(argc, argv); |
260 } | 260 } |
OLD | NEW |