| Index: device/bluetooth/bluetooth_adapter_mac.mm
|
| diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
|
| index bf108eee4c0b52fbb48eab66c3e4a2f1716233a8..d20163e2d0a849f56fce3cb61dfe5aac660e69ad 100644
|
| --- a/device/bluetooth/bluetooth_adapter_mac.mm
|
| +++ b/device/bluetooth/bluetooth_adapter_mac.mm
|
| @@ -24,6 +24,7 @@
|
| #include "base/time/time.h"
|
| #include "device/bluetooth/bluetooth_classic_device_mac.h"
|
| #include "device/bluetooth/bluetooth_discovery_session.h"
|
| +#include "device/bluetooth/bluetooth_gatt_connection_mac.h"
|
| #include "device/bluetooth/bluetooth_low_energy_central_manager_delegate.h"
|
| #include "device/bluetooth/bluetooth_socket_mac.h"
|
| #include "device/bluetooth/bluetooth_uuid.h"
|
| @@ -460,7 +461,8 @@ void BluetoothAdapterMac::LowEnergyDeviceUpdated(
|
| if (!device_reference) {
|
| // A new device has been found.
|
| device_reference =
|
| - new BluetoothLowEnergyDeviceMac(peripheral, advertisement_data, rssi);
|
| + new BluetoothLowEnergyDeviceMac(peripheral, advertisement_data, rssi,
|
| + this, low_energy_central_manager_);
|
| FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
|
| DeviceAdded(this, device_reference));
|
| return;
|
| @@ -522,4 +524,63 @@ void BluetoothAdapterMac::AddPairedDevices() {
|
| }
|
| }
|
|
|
| +void BluetoothAdapterMac::DidConnectPeripheral(CBPeripheral* peripheral) {
|
| + std::string address =
|
| + BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
|
| + BluetoothLowEnergyDeviceMac* device =
|
| + static_cast<BluetoothLowEnergyDeviceMac*>(devices_[address]);
|
| +
|
| + for (BluetoothDevice::GattConnectionCallback connect_success_callback :
|
| + device->create_gatt_connection_success_callbacks_) {
|
| + scoped_ptr<device::BluetoothGattConnection> connection(
|
| + new BluetoothGattConnectionMac(this, GetAddress()));
|
| + connect_success_callback.Run(connection.Pass());
|
| + }
|
| + for (ErrorCallback disconnect_error_callback :
|
| + device->disconnect_error_callbacks_) {
|
| + disconnect_error_callback.Run();
|
| + }
|
| + device->ClearConnectionCallbacks();
|
| +}
|
| +
|
| +void BluetoothAdapterMac::DidConnectPeripheralError(CBPeripheral* peripheral,
|
| + NSError* error) {
|
| + std::string address =
|
| + BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
|
| + BluetoothLowEnergyDeviceMac* device =
|
| + static_cast<BluetoothLowEnergyDeviceMac*>(devices_[address]);
|
| +
|
| + for (BluetoothDevice::ConnectErrorCallback connect_error_callback :
|
| + device->create_gatt_connection_error_callbacks_) {
|
| + BluetoothDevice::ConnectErrorCode error_code =
|
| + BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN;
|
| + connect_error_callback.Run(error_code);
|
| + }
|
| + for (base::Closure disconnect_success_callback :
|
| + device->disconnect_success_callbacks_) {
|
| + disconnect_success_callback.Run();
|
| + }
|
| + device->ClearConnectionCallbacks();
|
| +}
|
| +
|
| +void BluetoothAdapterMac::DidDisconnectPeripheral(CBPeripheral* peripheral,
|
| + NSError* error) {
|
| + std::string address =
|
| + BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
|
| + BluetoothLowEnergyDeviceMac* device =
|
| + static_cast<BluetoothLowEnergyDeviceMac*>(devices_[address]);
|
| +
|
| + for (BluetoothDevice::ConnectErrorCallback connect_error_callback :
|
| + device->create_gatt_connection_error_callbacks_) {
|
| + BluetoothDevice::ConnectErrorCode error_code =
|
| + BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN;
|
| + connect_error_callback.Run(error_code);
|
| + }
|
| + for (base::Closure disconnect_success_callback :
|
| + device->disconnect_success_callbacks_) {
|
| + disconnect_success_callback.Run();
|
| + }
|
| + device->ClearConnectionCallbacks();
|
| +}
|
| +
|
| } // namespace device
|
|
|