| 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..4d6e3025e86e8c6af0e3f2cac30ff95178a75b9f 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,22 @@ 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);
|
| + }
|
| +}
|
| +
|
| CBPeripheralState BluetoothLowEnergyDeviceMac::GetPeripheralState() const {
|
| Class peripheral_class = NSClassFromString(@"CBPeripheral");
|
| base::scoped_nsobject<NSMethodSignature> signature([[peripheral_class
|
|
|