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

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: DeviceRemoved obsolete in OSX. 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..b5ef7064ac1fc3777c8bebb28ed291d84fed2fc9 100644
--- a/device/bluetooth/bluetooth_device_mac.mm
+++ b/device/bluetooth/bluetooth_device_mac.mm
@@ -4,16 +4,27 @@
#include "device/bluetooth/bluetooth_device_mac.h"
+#import <IOBluetooth/objc/IOBluetoothDevice.h>
+#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(base::SysNSStringToUTF8([device name]),
+ base::SysNSStringToUTF8([device addressString]),
+ [device classOfDevice],
+ [device isConnected],
+ [device isPaired]),
+ device_fingerprint_(ComputeDeviceFingerprint(device)) {
}
BluetoothDeviceMac::~BluetoothDeviceMac() {
@@ -107,4 +118,25 @@ void BluetoothDeviceMac::ClearOutOfBandPairingData(
NOTIMPLEMENTED();
}
+// static
+uint32 BluetoothDeviceMac::ComputeDeviceFingerprint(
+ const IOBluetoothDevice* device) {
+ std::string device_string = base::StringPrintf("|%s|%s|%u|%d|%d|",
Mark Mentovai 2013/03/19 19:14:20 The first and last | characters aren’t necessary.
youngki 2013/03/20 18:48:27 Done.
+ base::SysNSStringToUTF8([device name]).c_str(),
+ base::SysNSStringToUTF8([device addressString]).c_str(),
+ [device classOfDevice],
+ [device isConnected],
+ [device isPaired]);
+
+ for (IOBluetoothSDPServiceRecord* record in [device services]) {
+ base::StringAppendF(
+ &device_string,
+ "|%s|%u|",
Mark Mentovai 2013/03/19 19:14:20 The last | character isn’t necessary.
youngki 2013/03/20 18:48:27 Done.
+ base::SysNSStringToUTF8([record getServiceName]).c_str(),
+ [[record attributes] count]);
+ }
+
+ return base::Hash(device_string);
+}
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698