| 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 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } | 255 } |
| 256 | 256 |
| 257 device::BluetoothAdapterMac* BluetoothLowEnergyDeviceMac::GetMacAdapter() { | 257 device::BluetoothAdapterMac* BluetoothLowEnergyDeviceMac::GetMacAdapter() { |
| 258 return static_cast<BluetoothAdapterMac*>(this->adapter_); | 258 return static_cast<BluetoothAdapterMac*>(this->adapter_); |
| 259 } | 259 } |
| 260 | 260 |
| 261 CBPeripheral* BluetoothLowEnergyDeviceMac::GetPeripheral() { | 261 CBPeripheral* BluetoothLowEnergyDeviceMac::GetPeripheral() { |
| 262 return peripheral_; | 262 return peripheral_; |
| 263 } | 263 } |
| 264 | 264 |
| 265 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral() { | 265 void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral( |
| 266 BluetoothDevice::ConnectErrorCode error_code) { |
| 266 if (create_gatt_connection_error_callbacks_.empty()) { | 267 if (create_gatt_connection_error_callbacks_.empty()) { |
| 268 // TODO(http://crbug.com/585897): Need to pass the error. |
| 267 DidDisconnectGatt(); | 269 DidDisconnectGatt(); |
| 268 } else { | 270 } else { |
| 269 DidFailToConnectGatt(ERROR_FAILED); | 271 DidFailToConnectGatt(error_code); |
| 270 } | 272 } |
| 271 } | 273 } |
| 272 | 274 |
| 273 CBPeripheralState BluetoothLowEnergyDeviceMac::GetPeripheralState() const { | 275 CBPeripheralState BluetoothLowEnergyDeviceMac::GetPeripheralState() const { |
| 274 Class peripheral_class = NSClassFromString(@"CBPeripheral"); | 276 Class peripheral_class = NSClassFromString(@"CBPeripheral"); |
| 275 base::scoped_nsobject<NSMethodSignature> signature([[peripheral_class | 277 base::scoped_nsobject<NSMethodSignature> signature([[peripheral_class |
| 276 instanceMethodSignatureForSelector:@selector(state)] retain]); | 278 instanceMethodSignatureForSelector:@selector(state)] retain]); |
| 277 base::scoped_nsobject<NSInvocation> invocation( | 279 base::scoped_nsobject<NSInvocation> invocation( |
| 278 [[NSInvocation invocationWithMethodSignature:signature] retain]); | 280 [[NSInvocation invocationWithMethodSignature:signature] retain]); |
| 279 [invocation setTarget:peripheral_]; | 281 [invocation setTarget:peripheral_]; |
| 280 [invocation setSelector:@selector(state)]; | 282 [invocation setSelector:@selector(state)]; |
| 281 [invocation invoke]; | 283 [invocation invoke]; |
| 282 CBPeripheralState state = CBPeripheralStateDisconnected; | 284 CBPeripheralState state = CBPeripheralStateDisconnected; |
| 283 [invocation getReturnValue:&state]; | 285 [invocation getReturnValue:&state]; |
| 284 return state; | 286 return state; |
| 285 } | 287 } |
| OLD | NEW |