Chromium Code Reviews| Index: device/bluetooth/bluetooth_adapter.cc |
| diff --git a/device/bluetooth/bluetooth_adapter.cc b/device/bluetooth/bluetooth_adapter.cc |
| index 286815970dc7ec753539de13b45a8e3472a33369..00c71b3a6c4ace808f55996153aa80a517507c37 100644 |
| --- a/device/bluetooth/bluetooth_adapter.cc |
| +++ b/device/bluetooth/bluetooth_adapter.cc |
| @@ -29,16 +29,6 @@ void BluetoothAdapter::StartDiscoverySession( |
| error_callback); |
| } |
| -void BluetoothAdapter::StartDiscovering(const base::Closure& callback, |
| - const ErrorCallback& error_callback) { |
| - AddDiscoverySession(callback, error_callback); |
| -} |
| - |
| -void BluetoothAdapter::StopDiscovering(const base::Closure& callback, |
| - const ErrorCallback& error_callback) { |
| - RemoveDiscoverySession(callback, error_callback); |
| -} |
| - |
| BluetoothAdapter::DeviceList BluetoothAdapter::GetDevices() { |
| ConstDeviceList const_devices = |
| const_cast<const BluetoothAdapter *>(this)->GetDevices(); |
| @@ -119,14 +109,21 @@ void BluetoothAdapter::OnStartDiscoverySession( |
| } |
| void BluetoothAdapter::MarkDiscoverySessionsAsInactive() { |
| + // As sessions are marked as inactive they will notify the adapter that they |
| + // have become inactive, upon which the adapter will remove them from |
| + // |discovery_sessions_|. To avoid invalidating the iterator, make a copy |
| + // here and clear the original list as it is meant to have become empty after |
| + // this method returns. |
| + std::set<BluetoothDiscoverySession*> temp(discovery_sessions_); |
| + discovery_sessions_.clear(); |
|
keybuk
2014/03/07 19:34:36
if the discovery session is marking itself as inac
armansito
2014/03/07 19:56:52
I guess it's a bit redundant, and a call to erase
|
| for (std::set<BluetoothDiscoverySession*>::iterator |
| - iter = discovery_sessions_.begin(); |
| - iter != discovery_sessions_.end(); ++iter) { |
| + iter = temp.begin(); |
| + iter != temp.end(); ++iter) { |
| (*iter)->MarkAsInactive(); |
| } |
| } |
| -void BluetoothAdapter::DiscoverySessionDestroyed( |
| +void BluetoothAdapter::DiscoverySessionBecameInactive( |
| BluetoothDiscoverySession* discovery_session) { |
| discovery_sessions_.erase(discovery_session); |
| } |