| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_low_energy_device_mac.h" | 5 #include "device/bluetooth/bluetooth_low_energy_device_mac.h" |
| 6 | 6 |
| 7 #import <CoreFoundation/CoreFoundation.h> | 7 #import <CoreFoundation/CoreFoundation.h> |
| 8 | 8 |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 device::BluetoothUUID BluetoothUUIDWithCBUUID(CBUUID* uuid) { | 23 device::BluetoothUUID BluetoothUUIDWithCBUUID(CBUUID* uuid) { |
| 24 // UUIDString only available OS X >= 10.8. | 24 // UUIDString only available OS X >= 10.8. |
| 25 DCHECK(base::mac::IsOSMountainLionOrLater()); | 25 DCHECK(base::mac::IsOSMountainLionOrLater()); |
| 26 std::string uuid_c_string = base::SysNSStringToUTF8([uuid UUIDString]); | 26 std::string uuid_c_string = base::SysNSStringToUTF8([uuid UUIDString]); |
| 27 return device::BluetoothUUID(uuid_c_string); | 27 return device::BluetoothUUID(uuid_c_string); |
| 28 } | 28 } |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 BluetoothLowEnergyDeviceMac::BluetoothLowEnergyDeviceMac( | 32 BluetoothLowEnergyDeviceMac::BluetoothLowEnergyDeviceMac( |
| 33 BluetoothAdapterMac* adapter, |
| 33 CBPeripheral* peripheral, | 34 CBPeripheral* peripheral, |
| 34 NSDictionary* advertisement_data, | 35 NSDictionary* advertisement_data, |
| 35 int rssi) { | 36 int rssi) |
| 37 : BluetoothDeviceMac(adapter) { |
| 36 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); | 38 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); |
| 37 identifier_ = GetPeripheralIdentifier(peripheral); | 39 identifier_ = GetPeripheralIdentifier(peripheral); |
| 38 hash_address_ = GetPeripheralHashAddress(peripheral); | 40 hash_address_ = GetPeripheralHashAddress(peripheral); |
| 39 Update(peripheral, advertisement_data, rssi); | 41 Update(peripheral, advertisement_data, rssi); |
| 40 } | 42 } |
| 41 | 43 |
| 42 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { | 44 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { |
| 43 } | 45 } |
| 44 | 46 |
| 45 void BluetoothLowEnergyDeviceMac::Update(CBPeripheral* peripheral, | 47 void BluetoothLowEnergyDeviceMac::Update(CBPeripheral* peripheral, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 instanceMethodSignatureForSelector:@selector(state)] retain]); | 247 instanceMethodSignatureForSelector:@selector(state)] retain]); |
| 246 base::scoped_nsobject<NSInvocation> invocation( | 248 base::scoped_nsobject<NSInvocation> invocation( |
| 247 [[NSInvocation invocationWithMethodSignature:signature] retain]); | 249 [[NSInvocation invocationWithMethodSignature:signature] retain]); |
| 248 [invocation setTarget:peripheral_]; | 250 [invocation setTarget:peripheral_]; |
| 249 [invocation setSelector:@selector(state)]; | 251 [invocation setSelector:@selector(state)]; |
| 250 [invocation invoke]; | 252 [invocation invoke]; |
| 251 CBPeripheralState state = CBPeripheralStateDisconnected; | 253 CBPeripheralState state = CBPeripheralStateDisconnected; |
| 252 [invocation getReturnValue:&state]; | 254 [invocation getReturnValue:&state]; |
| 253 return state; | 255 return state; |
| 254 } | 256 } |
| OLD | NEW |