Index: chromeos/geolocation/simple_geolocation_provider.cc |
diff --git a/chromeos/geolocation/simple_geolocation_provider.cc b/chromeos/geolocation/simple_geolocation_provider.cc |
index 4a57ac7919bfac41ed4dc7a608b5b098650ff479..e083b3edb0460b911f5c2e1398bfc8f75851dd52 100644 |
--- a/chromeos/geolocation/simple_geolocation_provider.cc |
+++ b/chromeos/geolocation/simple_geolocation_provider.cc |
@@ -62,10 +62,13 @@ void SimpleGeolocationProvider::OnGeolocationResponse( |
callback.Run(geoposition, server_error, elapsed); |
- ScopedVector<SimpleGeolocationRequest>::iterator new_end = |
- std::remove(requests_.begin(), requests_.end(), request); |
- DCHECK_EQ(std::distance(new_end, requests_.end()), 1); |
- requests_.erase(new_end, requests_.end()); |
+ ScopedVector<SimpleGeolocationRequest>::iterator position = |
+ std::find(requests_.begin(), requests_.end(), request); |
+ DCHECK(position != requests_.end()); |
+ if (position != requests_.end()) { |
+ std::swap(*position, *requests_.rbegin()); |
+ requests_.resize(requests_.size() - 1); |
+ } |
} |
} // namespace chromeos |