| 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(BluetoothDevice::ERROR_FAILED); |
| 270 } | 272 } |
| 271 } | 273 } |
| 272 | 274 |
| 273 void BluetoothLowEnergyDeviceMac::GattConnected() { | 275 void BluetoothLowEnergyDeviceMac::GattConnected() { |
| 274 DidConnectGatt(); | 276 DidConnectGatt(); |
| 275 } | 277 } |
| 276 | 278 |
| 277 CBPeripheralState BluetoothLowEnergyDeviceMac::GetPeripheralState() const { | 279 CBPeripheralState BluetoothLowEnergyDeviceMac::GetPeripheralState() const { |
| 278 Class peripheral_class = NSClassFromString(@"CBPeripheral"); | 280 Class peripheral_class = NSClassFromString(@"CBPeripheral"); |
| 279 base::scoped_nsobject<NSMethodSignature> signature([[peripheral_class | 281 base::scoped_nsobject<NSMethodSignature> signature([[peripheral_class |
| 280 instanceMethodSignatureForSelector:@selector(state)] retain]); | 282 instanceMethodSignatureForSelector:@selector(state)] retain]); |
| 281 base::scoped_nsobject<NSInvocation> invocation( | 283 base::scoped_nsobject<NSInvocation> invocation( |
| 282 [[NSInvocation invocationWithMethodSignature:signature] retain]); | 284 [[NSInvocation invocationWithMethodSignature:signature] retain]); |
| 283 [invocation setTarget:peripheral_]; | 285 [invocation setTarget:peripheral_]; |
| 284 [invocation setSelector:@selector(state)]; | 286 [invocation setSelector:@selector(state)]; |
| 285 [invocation invoke]; | 287 [invocation invoke]; |
| 286 CBPeripheralState state = CBPeripheralStateDisconnected; | 288 CBPeripheralState state = CBPeripheralStateDisconnected; |
| 287 [invocation getReturnValue:&state]; | 289 [invocation getReturnValue:&state]; |
| 288 return state; | 290 return state; |
| 289 } | 291 } |
| OLD | NEW |