OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "device/bluetooth/bluetooth_task_manager_win.h" | 5 #include "device/bluetooth/bluetooth_task_manager_win.h" |
6 | 6 |
7 #include <winsock2.h> | 7 #include <winsock2.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_, | 181 FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_, |
182 DiscoveryStarted(success)); | 182 DiscoveryStarted(success)); |
183 } | 183 } |
184 | 184 |
185 void BluetoothTaskManagerWin::OnDiscoveryStopped() { | 185 void BluetoothTaskManagerWin::OnDiscoveryStopped() { |
186 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 186 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
187 FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_, | 187 FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_, |
188 DiscoveryStopped()); | 188 DiscoveryStopped()); |
189 } | 189 } |
190 | 190 |
| 191 void BluetoothTaskManagerWin::OnDevicesUpdated( |
| 192 const ScopedVector<DeviceState>* devices) { |
| 193 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 194 FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_, |
| 195 DevicesUpdated(*devices)); |
| 196 } |
| 197 |
191 void BluetoothTaskManagerWin::OnDevicesDiscovered( | 198 void BluetoothTaskManagerWin::OnDevicesDiscovered( |
192 const ScopedVector<DeviceState>* devices) { | 199 const ScopedVector<DeviceState>* devices) { |
193 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 200 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
194 FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_, | 201 FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_, |
195 DevicesDiscovered(*devices)); | 202 DevicesDiscovered(*devices)); |
196 } | 203 } |
197 | 204 |
198 void BluetoothTaskManagerWin::PollAdapter() { | 205 void BluetoothTaskManagerWin::PollAdapter() { |
199 DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread()); | 206 DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread()); |
200 | 207 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 void BluetoothTaskManagerWin::GetKnownDevices() { | 321 void BluetoothTaskManagerWin::GetKnownDevices() { |
315 ScopedVector<DeviceState>* device_list = new ScopedVector<DeviceState>(); | 322 ScopedVector<DeviceState>* device_list = new ScopedVector<DeviceState>(); |
316 SearchDevices(1, true, device_list); | 323 SearchDevices(1, true, device_list); |
317 if (device_list->empty()) { | 324 if (device_list->empty()) { |
318 delete device_list; | 325 delete device_list; |
319 return; | 326 return; |
320 } | 327 } |
321 DiscoverServices(device_list); | 328 DiscoverServices(device_list); |
322 ui_task_runner_->PostTask( | 329 ui_task_runner_->PostTask( |
323 FROM_HERE, | 330 FROM_HERE, |
324 base::Bind(&BluetoothTaskManagerWin::OnDevicesDiscovered, | 331 base::Bind(&BluetoothTaskManagerWin::OnDevicesUpdated, |
325 this, | 332 this, |
326 base::Owned(device_list))); | 333 base::Owned(device_list))); |
327 } | 334 } |
328 | 335 |
329 void BluetoothTaskManagerWin::SearchDevices( | 336 void BluetoothTaskManagerWin::SearchDevices( |
330 int timeout, | 337 int timeout, |
331 bool search_cached_devices_only, | 338 bool search_cached_devices_only, |
332 ScopedVector<DeviceState>* device_list) { | 339 ScopedVector<DeviceState>* device_list) { |
333 BLUETOOTH_DEVICE_SEARCH_PARAMS device_search_params = { | 340 BLUETOOTH_DEVICE_SEARCH_PARAMS device_search_params = { |
334 sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS), | 341 sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS), |
335 1, // return authenticated devices | 342 1, // return authenticated devices |
336 1, // return remembered devices | 343 1, // return remembered devicess |
337 search_cached_devices_only ? 0 : 1, // return unknown devices | 344 search_cached_devices_only ? 0 : 1, // return unknown devices |
338 1, // return connected devices | 345 1, // return connected devices |
339 search_cached_devices_only ? 0 : 1, // issue a new inquiry | 346 search_cached_devices_only ? 0 : 1, // issue a new inquiry |
340 timeout, // timeout for the inquiry in increments of 1.28 seconds | 347 timeout, // timeout for the inquiry in increments of 1.28 seconds |
341 adapter_handle_ | 348 adapter_handle_ |
342 }; | 349 }; |
343 | 350 |
344 BLUETOOTH_DEVICE_INFO device_info = { sizeof(BLUETOOTH_DEVICE_INFO), 0 }; | 351 BLUETOOTH_DEVICE_INFO device_info = { sizeof(BLUETOOTH_DEVICE_INFO), 0 }; |
345 // Issues a device inquiry and waits for |timeout| * 1.28 seconds. | 352 // Issues a device inquiry and waits for |timeout| * 1.28 seconds. |
346 HBLUETOOTH_DEVICE_FIND handle = | 353 HBLUETOOTH_DEVICE_FIND handle = |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 service_record_state->sdp_bytes.push_back( | 405 service_record_state->sdp_bytes.push_back( |
399 sdp_result_data->lpBlob->pBlobData[i]); | 406 sdp_result_data->lpBlob->pBlobData[i]); |
400 } | 407 } |
401 service_record_states->push_back(service_record_state); | 408 service_record_states->push_back(service_record_state); |
402 } | 409 } |
403 WSALookupServiceEnd(sdp_handle); | 410 WSALookupServiceEnd(sdp_handle); |
404 } | 411 } |
405 } | 412 } |
406 | 413 |
407 } // namespace device | 414 } // namespace device |
OLD | NEW |