| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/geolocation/simple_geolocation_provider.h" | 5 #include "chromeos/geolocation/simple_geolocation_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 void SimpleGeolocationProvider::OnGeolocationResponse( | 55 void SimpleGeolocationProvider::OnGeolocationResponse( |
| 56 SimpleGeolocationRequest* request, | 56 SimpleGeolocationRequest* request, |
| 57 SimpleGeolocationRequest::ResponseCallback callback, | 57 SimpleGeolocationRequest::ResponseCallback callback, |
| 58 const Geoposition& geoposition, | 58 const Geoposition& geoposition, |
| 59 bool server_error, | 59 bool server_error, |
| 60 const base::TimeDelta elapsed) { | 60 const base::TimeDelta elapsed) { |
| 61 DCHECK(thread_checker_.CalledOnValidThread()); | 61 DCHECK(thread_checker_.CalledOnValidThread()); |
| 62 | 62 |
| 63 callback.Run(geoposition, server_error, elapsed); | 63 callback.Run(geoposition, server_error, elapsed); |
| 64 | 64 |
| 65 ScopedVector<SimpleGeolocationRequest>::iterator position = | 65 ScopedVector<SimpleGeolocationRequest>::iterator new_end = |
| 66 std::find(requests_.begin(), requests_.end(), request); | 66 std::remove(requests_.begin(), requests_.end(), request); |
| 67 DCHECK_NE(&(*position), &(*requests_.end())); | 67 DCHECK_EQ(std::distance(new_end, requests_.end()), 1); |
| 68 if (position != requests_.end()) { | 68 requests_.erase(new_end, requests_.end()); |
| 69 std::swap(*position, *requests_.rbegin()); | |
| 70 requests_.resize(requests_.size() - 1); | |
| 71 } | |
| 72 } | 69 } |
| 73 | 70 |
| 74 } // namespace chromeos | 71 } // namespace chromeos |
| OLD | NEW |