| 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 0573c2fc11b8cb11d9e70db97c3c4e87b78518d8..dc36c2f382b28b651905db8d4cdbfd3493e8f6f7 100644
|
| --- a/device/bluetooth/bluetooth_low_energy_device_mac.mm
|
| +++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm
|
| @@ -322,15 +322,11 @@ BluetoothLowEnergyDeviceMac::GetBluetoothRemoteGattService(
|
| void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral(
|
| BluetoothDevice::ConnectErrorCode error_code) {
|
| SetGattServicesDiscoveryComplete(false);
|
| - // Explicitly take and erase GATT services one by one to ensure that calling
|
| - // GetGattService on removed service in GattServiceRemoved returns null.
|
| - std::vector<std::string> service_keys;
|
| - for (const auto& gatt_service : gatt_services_) {
|
| - service_keys.push_back(gatt_service.first);
|
| - }
|
| - for (const auto& key : service_keys) {
|
| - gatt_services_.take_and_erase(key);
|
| - }
|
| + // 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();
|
| if (create_gatt_connection_error_callbacks_.empty()) {
|
| // TODO(http://crbug.com/585897): Need to pass the error.
|
| DidDisconnectGatt();
|
|
|