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

Unified Diff: device/bluetooth/bluetooth_device_mac.mm

Issue 12929003: Implemented BluetoothAdapterMac::AddDevices(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 months 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
Index: device/bluetooth/bluetooth_device_mac.mm
diff --git a/device/bluetooth/bluetooth_device_mac.mm b/device/bluetooth/bluetooth_device_mac.mm
index d0a676203e29454e61b43c1d73cbdee12ff66462..f454f0afb6694d716d22dc27a52e63f5c5ace541 100644
--- a/device/bluetooth/bluetooth_device_mac.mm
+++ b/device/bluetooth/bluetooth_device_mac.mm
@@ -4,21 +4,37 @@
#include "device/bluetooth/bluetooth_device_mac.h"
+#import <IObluetooth/objc/IOBluetoothDevice.h>
Mark Mentovai 2013/03/19 16:04:35 Fix capitalization.
youngki 2013/03/19 19:04:55 Done.
+#import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h>
+
#include <string>
#include "base/basictypes.h"
+#include "base/hash.h"
+#include "base/stringprintf.h"
+#include "base/strings/sys_string_conversions.h"
#include "device/bluetooth/bluetooth_out_of_band_pairing_data.h"
#include "device/bluetooth/bluetooth_service_record_mac.h"
namespace device {
-BluetoothDeviceMac::BluetoothDeviceMac()
- : BluetoothDevice() {
+BluetoothDeviceMac::BluetoothDeviceMac(const IOBluetoothDevice* device)
+ : BluetoothDevice(),
+ device_fingerprint_(ComputeDeviceFingerprint(device)) {
+ name_ = base::SysNSStringToUTF8([device name]);
Mark Mentovai 2013/03/19 16:04:35 You can list all of these in the initializer list.
youngki 2013/03/19 19:04:55 Done.
+ address_ = base::SysNSStringToUTF8([device addressString]);
+ bluetooth_class_ = [device classOfDevice];
+ connected_ = [device isConnected];
+ bonded_ = [device isPaired];
}
BluetoothDeviceMac::~BluetoothDeviceMac() {
}
+void BluetoothDeviceMac::SetVisible(bool visible) {
+ visible_ = visible;
+}
+
bool BluetoothDeviceMac::IsPaired() const {
return false;
}
@@ -107,4 +123,25 @@ void BluetoothDeviceMac::ClearOutOfBandPairingData(
NOTIMPLEMENTED();
}
+// static
+uint32 BluetoothDeviceMac::ComputeDeviceFingerprint(
+ const IOBluetoothDevice* device) {
+ std::string device_string = base::StringPrintf("%s%s%u%s%s",
Mark Mentovai 2013/03/19 16:04:35 For fields without fixed width, can you have the d
youngki 2013/03/19 19:04:55 Done.
+ base::SysNSStringToUTF8([device name]).c_str(),
+ base::SysNSStringToUTF8([device addressString]).c_str(),
+ [device classOfDevice],
+ [device isConnected] ? "true" : "false",
Mark Mentovai 2013/03/19 16:04:35 You don’t need to turn these into strings, you can
youngki 2013/03/19 19:04:55 Done.
+ [device isPaired] ? "true" : "false");
+
+ for (IOBluetoothSDPServiceRecord* record in [device services]) {
+ base::StringAppendF(
+ &device_string,
+ "%s%u",
+ base::SysNSStringToUTF8([record getServiceName]).c_str(),
+ [[record sortedAttributes] count]);
Mark Mentovai 2013/03/19 16:04:35 If you’re just getting a count, you don’t care if
youngki 2013/03/19 19:04:55 Done.
+ }
+
+ return base::Hash(device_string);
+}
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698