Index: device/bluetooth/bluetooth_manager_win.cc |
diff --git a/device/bluetooth/bluetooth_manager_win.cc b/device/bluetooth/bluetooth_manager_win.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e3fef5450143471a7cf14a6cd8112ccc9a7a9376 |
--- /dev/null |
+++ b/device/bluetooth/bluetooth_manager_win.cc |
@@ -0,0 +1,52 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "device/bluetooth/bluetooth_manager_win.h" |
+ |
+#include <BluetoothAPIs.h> |
+#include "base/callback.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "device/bluetooth/bluetooth_adapter_win.h" |
+ |
+# pragma comment(lib, "Bthprops.lib") |
+ |
+namespace { |
+ |
+ const char* kBluetoothManagerThreadName = "BluetoothManagerThread"; |
bryeung
2012/11/22 18:13:25
no indent
youngki
2012/11/23 01:50:47
Done.
|
+ const BLUETOOTH_FIND_RADIO_PARAMS adapter_param = |
+ { sizeof(BLUETOOTH_FIND_RADIO_PARAMS) }; |
bryeung
2012/11/22 18:13:25
blank line
youngki
2012/11/23 01:50:47
Done.
|
+} // namespace |
+ |
+namespace device { |
+ |
+BluetoothManagerWin::BluetoothManagerWin() |
+ : Thread(kBluetoothManagerThreadName) {} |
+ |
+BluetoothManagerWin::~BluetoothManagerWin() { |
+ Stop(); |
+} |
+ |
+void BluetoothManagerWin::FindAdapterHandleAndReply( |
+ base::WeakPtr<BluetoothAdapterWin> weak_ptr) { |
+ HANDLE adapter_handle = FindAdapterHandle(); |
+ |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&BluetoothAdapterWin::OnAdapterHandleAvailable, |
+ weak_ptr, |
+ adapter_handle)); |
+} |
+ |
+HANDLE BluetoothManagerWin::FindAdapterHandle() { |
+ HBLUETOOTH_RADIO_FIND adapter_handle = NULL; |
+ HBLUETOOTH_RADIO_FIND handle = BluetoothFindFirstRadio(&adapter_param, |
+ &adapter_handle); |
+ if (handle) |
+ BluetoothFindRadioClose(handle); |
+ |
+ return adapter_handle; |
+} |
+ |
+} // namespace device |