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 0573c2fc11b8cb11d9e70db97c3c4e87b78518d8..8b84c726670a8f2a9e1506024f57def370548caa 100644 |
| --- a/device/bluetooth/bluetooth_low_energy_device_mac.mm |
| +++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm |
| @@ -322,15 +322,10 @@ 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. |
|
ortuno
2016/05/10 19:40:14
nit: Keep the part of the comment about GetGattSer
|
| + 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(); |