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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 void BluetoothTaskManagerWin::PollAdapter() { | 205 void BluetoothTaskManagerWin::PollAdapter() { |
206 DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread()); | 206 DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread()); |
207 | 207 |
208 // Skips updating the adapter info if the adapter is in discovery mode. | 208 // Skips updating the adapter info if the adapter is in discovery mode. |
209 if (!discovering_) { | 209 if (!discovering_) { |
210 const BLUETOOTH_FIND_RADIO_PARAMS adapter_param = | 210 const BLUETOOTH_FIND_RADIO_PARAMS adapter_param = |
211 { sizeof(BLUETOOTH_FIND_RADIO_PARAMS) }; | 211 { sizeof(BLUETOOTH_FIND_RADIO_PARAMS) }; |
212 if (adapter_handle_) | 212 if (adapter_handle_) |
213 adapter_handle_.Close(); | 213 adapter_handle_.Close(); |
214 HANDLE temp_adapter_handle; | |
215 HBLUETOOTH_RADIO_FIND handle = BluetoothFindFirstRadio( | 214 HBLUETOOTH_RADIO_FIND handle = BluetoothFindFirstRadio( |
216 &adapter_param, &temp_adapter_handle); | 215 &adapter_param, adapter_handle_.Receive()); |
217 | 216 |
218 if (handle) { | 217 if (handle) { |
219 adapter_handle_.Set(temp_adapter_handle); | |
220 GetKnownDevices(); | 218 GetKnownDevices(); |
221 BluetoothFindRadioClose(handle); | 219 BluetoothFindRadioClose(handle); |
222 } | 220 } |
223 PostAdapterStateToUi(); | 221 PostAdapterStateToUi(); |
224 } | 222 } |
225 | 223 |
226 // Re-poll. | 224 // Re-poll. |
227 bluetooth_task_runner_->PostDelayedTask( | 225 bluetooth_task_runner_->PostDelayedTask( |
228 FROM_HERE, | 226 FROM_HERE, |
229 base::Bind(&BluetoothTaskManagerWin::PollAdapter, | 227 base::Bind(&BluetoothTaskManagerWin::PollAdapter, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 service_record_state->sdp_bytes.push_back( | 405 service_record_state->sdp_bytes.push_back( |
408 sdp_result_data->lpBlob->pBlobData[i]); | 406 sdp_result_data->lpBlob->pBlobData[i]); |
409 } | 407 } |
410 service_record_states->push_back(service_record_state); | 408 service_record_states->push_back(service_record_state); |
411 } | 409 } |
412 WSALookupServiceEnd(sdp_handle); | 410 WSALookupServiceEnd(sdp_handle); |
413 } | 411 } |
414 } | 412 } |
415 | 413 |
416 } // namespace device | 414 } // namespace device |
OLD | NEW |