Chromium Code Reviews| Index: device/bluetooth/bluetooth_low_energy_device_mac.mm |
| diff --git a/device/bluetooth/bluetooth_low_energy_device_mac.mm b/device/bluetooth/bluetooth_low_energy_device_mac.mm |
| index 677c59557087bc8be0e1cb5f92a9d631ec910e7b..1ca4a45f34c3049a0d758e421d9c0488738727ea 100644 |
| --- a/device/bluetooth/bluetooth_low_energy_device_mac.mm |
| +++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm |
| @@ -43,6 +43,9 @@ BluetoothLowEnergyDeviceMac::BluetoothLowEnergyDeviceMac( |
| } |
| BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { |
| + if (IsGattConnected()) { |
| + GetMacAdapter()->DisconnectGatt(this); |
| + } |
| } |
| void BluetoothLowEnergyDeviceMac::Update(CBPeripheral* peripheral, |
| @@ -127,7 +130,7 @@ bool BluetoothLowEnergyDeviceMac::IsConnectable() const { |
| } |
| bool BluetoothLowEnergyDeviceMac::IsConnecting() const { |
| - return false; |
| + return (GetPeripheralState() == CBPeripheralStateConnecting); |
| } |
| BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const { |
| @@ -213,12 +216,6 @@ void BluetoothLowEnergyDeviceMac::ConnectToServiceInsecurely( |
| NOTIMPLEMENTED(); |
| } |
| -void BluetoothLowEnergyDeviceMac::CreateGattConnection( |
| - const GattConnectionCallback& callback, |
| - const ConnectErrorCallback& error_callback) { |
| - NOTIMPLEMENTED(); |
| -} |
| - |
| NSDate* BluetoothLowEnergyDeviceMac::GetLastUpdateTime() const { |
| return last_update_time_.get(); |
| } |
| @@ -228,15 +225,13 @@ std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const { |
| } |
| void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() { |
| - // Mac implementation does not yet use the default CreateGattConnection |
| - // implementation. http://crbug.com/520774 |
| - NOTIMPLEMENTED(); |
| + if (!IsGattConnected()) { |
| + GetMacAdapter()->CreateGattConnection(this); |
| + } |
| } |
| void BluetoothLowEnergyDeviceMac::DisconnectGatt() { |
| - // Mac implementation does not yet use the default CreateGattConnection |
| - // implementation. http://crbug.com/520774 |
| - NOTIMPLEMENTED(); |
| + GetMacAdapter()->DisconnectGatt(this); |
| } |
| // static |
| @@ -259,6 +254,26 @@ std::string BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress( |
| return BluetoothDevice::CanonicalizeAddress(hash); |
| } |
| +device::BluetoothAdapterMac* BluetoothLowEnergyDeviceMac::GetMacAdapter() { |
| + return static_cast<BluetoothAdapterMac*>(this->adapter_); |
| +} |
| + |
| +CBPeripheral* BluetoothLowEnergyDeviceMac::GetPeripheral() { |
| + return peripheral_; |
| +} |
| + |
| +void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral() { |
| + if (create_gatt_connection_error_callbacks_.empty()) { |
| + DidDisconnectGatt(); |
| + } else { |
| + DidFailToConnectGatt(ERROR_FAILED); |
| + } |
| +} |
| + |
| +void BluetoothLowEnergyDeviceMac::GattConnected() { |
|
msarda
2016/02/11 10:55:39
This is a private method and I do not see where it
jlebel
2016/02/19 11:02:35
Done.
|
| + DidConnectGatt(); |
| +} |
| + |
| CBPeripheralState BluetoothLowEnergyDeviceMac::GetPeripheralState() const { |
| Class peripheral_class = NSClassFromString(@"CBPeripheral"); |
| base::scoped_nsobject<NSMethodSignature> signature([[peripheral_class |