Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Unified Diff: device/bluetooth/bluetooth_adapter_win.cc

Issue 11345037: Implemented BluetoothAdapterWin::IsPresent(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Match the definition order to the declaration order Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_adapter_win.h ('k') | device/bluetooth/bluetooth_adapter_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_adapter_win.cc
diff --git a/device/bluetooth/bluetooth_adapter_win.cc b/device/bluetooth/bluetooth_adapter_win.cc
index 97eca65763bbdb2245bc9a84cf82ced50b7ab675..2fe1f58d906aa209ac231be3c6138294856380cb 100644
--- a/device/bluetooth/bluetooth_adapter_win.cc
+++ b/device/bluetooth/bluetooth_adapter_win.cc
@@ -6,11 +6,27 @@
#include "device/bluetooth/bluetooth_adapter_win.h"
+#include <BluetoothAPIs.h>
#include <string>
+#include "base/bind.h"
#include "base/logging.h"
+#include "base/message_loop.h"
+#include "base/stringprintf.h"
+#include "base/sys_string_conversions.h"
+
+# pragma comment(lib, "Bthprops.lib")
+
+namespace {
+
+const BLUETOOTH_FIND_RADIO_PARAMS bluetooth_adapter_param =
+ { sizeof(BLUETOOTH_FIND_RADIO_PARAMS) };
+
+} // namespace
namespace device {
+const int BluetoothAdapterWin::kPollIntervalMs = 500;
+
BluetoothAdapterWin::BluetoothAdapterWin()
: BluetoothAdapter(),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
@@ -28,8 +44,7 @@ void BluetoothAdapterWin::RemoveObserver(BluetoothAdapter::Observer* observer) {
}
bool BluetoothAdapterWin::IsPresent() const {
- NOTIMPLEMENTED();
- return false;
+ return !address_.empty();
}
bool BluetoothAdapterWin::IsPowered() const {
@@ -78,4 +93,40 @@ void BluetoothAdapterWin::ReadLocalOutOfBandPairingData(
NOTIMPLEMENTED();
}
+void BluetoothAdapterWin::UpdateAdapterState() {
+ HBLUETOOTH_RADIO_FIND bluetooth_adapter_handle = NULL;
+ BLUETOOTH_RADIO_INFO bluetooth_adapter_info =
+ { sizeof(BLUETOOTH_RADIO_INFO), 0 };
+ BluetoothFindFirstRadio(&bluetooth_adapter_param, &bluetooth_adapter_handle);
+ if (bluetooth_adapter_handle &&
+ ERROR_SUCCESS == BluetoothGetRadioInfo(bluetooth_adapter_handle,
+ &bluetooth_adapter_info)) {
+ name_ = base::SysWideToUTF8(bluetooth_adapter_info.szName);
+ address_ = base::StringPrintf("%02X:%02X:%02X:%02X:%02X:%02X",
+ bluetooth_adapter_info.address.rgBytes[5],
+ bluetooth_adapter_info.address.rgBytes[4],
+ bluetooth_adapter_info.address.rgBytes[3],
+ bluetooth_adapter_info.address.rgBytes[2],
+ bluetooth_adapter_info.address.rgBytes[1],
+ bluetooth_adapter_info.address.rgBytes[0]);
+ } else {
+ name_.clear();
+ address_.clear();
+ }
+}
+
+void BluetoothAdapterWin::TrackDefaultAdapter() {
+ PollAdapterState();
+}
+
+void BluetoothAdapterWin::PollAdapterState() {
+ UpdateAdapterState();
+
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&BluetoothAdapterWin::PollAdapterState,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::TimeDelta::FromMilliseconds(kPollIntervalMs));
+}
+
} // namespace device
« no previous file with comments | « device/bluetooth/bluetooth_adapter_win.h ('k') | device/bluetooth/bluetooth_adapter_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698