Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: chromeos/geolocation/simple_geolocation_provider.cc

Issue 973003002: Fix crash in SimpleGeolocationProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK crash fixed. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chromeos/timezone/timezone_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 new_end = 65 ScopedVector<SimpleGeolocationRequest>::iterator position =
66 std::remove(requests_.begin(), requests_.end(), request); 66 std::find(requests_.begin(), requests_.end(), request);
67 DCHECK_EQ(std::distance(new_end, requests_.end()), 1); 67 DCHECK(position != requests_.end());
68 requests_.erase(new_end, requests_.end()); 68 if (position != requests_.end()) {
69 std::swap(*position, *requests_.rbegin());
70 requests_.resize(requests_.size() - 1);
71 }
69 } 72 }
70 73
71 } // namespace chromeos 74 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/timezone/timezone_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698