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 e335e5fb916f389b6e88d7b9bd285fcc3e72f114..aa38523dc2fc59e889341bd4dcc645eb64b9616a 100644 |
| --- a/device/bluetooth/bluetooth_low_energy_device_mac.mm |
| +++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm |
| @@ -391,14 +391,18 @@ BluetoothLowEnergyDeviceMac::GetBluetoothRemoteGattService( |
| return nullptr; |
| } |
| +void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral() { |
| + RemoveAllServices(); |
| + if (create_gatt_connection_error_callbacks_.empty()) { |
| + DidDisconnectGatt(); |
| + } else { |
| + DidFailToConnectGatt(BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN); |
| + } |
| +} |
| + |
| void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral( |
| BluetoothDevice::ConnectErrorCode error_code) { |
| - SetGattServicesDiscoveryComplete(false); |
| - // Removing all services at once to ensure that calling GetGattService on |
| - // removed service in GattServiceRemoved returns null. |
| - GattServiceMap gatt_services_swapped; |
| - gatt_services_swapped.swap(gatt_services_); |
| - gatt_services_swapped.clear(); |
| + RemoveAllServices(); |
| if (create_gatt_connection_error_callbacks_.empty()) { |
|
ortuno
2016/08/09 15:40:25
DidDisconnectPeripheral shouldn't be called after
jlebel
2016/08/09 16:23:58
I was guessing it disconnect is called before the
|
| // TODO(http://crbug.com/585897): Need to pass the error. |
| DidDisconnectGatt(); |
| @@ -406,3 +410,12 @@ void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral( |
| DidFailToConnectGatt(error_code); |
| } |
| } |
| + |
| +void BluetoothLowEnergyDeviceMac::RemoveAllServices() { |
| + SetGattServicesDiscoveryComplete(false); |
| + // Removing all services at once to ensure that calling GetGattService on |
| + // removed service in GattServiceRemoved returns null. |
| + GattServiceMap gatt_services_swapped; |
| + gatt_services_swapped.swap(gatt_services_); |
| + gatt_services_swapped.clear(); |
| +} |