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

Side by Side Diff: chromeos/timezone/timezone_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 | « chromeos/geolocation/simple_geolocation_provider.cc ('k') | no next file » | 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/timezone/timezone_provider.h" 5 #include "chromeos/timezone/timezone_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 29 matching lines...) Expand all
40 request, 40 request,
41 callback)); 41 callback));
42 request->MakeRequest(callback_tmp); 42 request->MakeRequest(callback_tmp);
43 } 43 }
44 44
45 void TimeZoneProvider::OnTimezoneResponse( 45 void TimeZoneProvider::OnTimezoneResponse(
46 TimeZoneRequest* request, 46 TimeZoneRequest* request,
47 TimeZoneRequest::TimeZoneResponseCallback callback, 47 TimeZoneRequest::TimeZoneResponseCallback callback,
48 scoped_ptr<TimeZoneResponseData> timezone, 48 scoped_ptr<TimeZoneResponseData> timezone,
49 bool server_error) { 49 bool server_error) {
50 ScopedVector<TimeZoneRequest>::iterator new_end = 50 ScopedVector<TimeZoneRequest>::iterator position =
51 std::remove(requests_.begin(), requests_.end(), request); 51 std::find(requests_.begin(), requests_.end(), request);
52 DCHECK_EQ(std::distance(new_end, requests_.end()), 1); 52 DCHECK(position != requests_.end());
53 requests_.erase(new_end, requests_.end()); 53 if (position != requests_.end()) {
54 std::swap(*position, *requests_.rbegin());
55 requests_.resize(requests_.size() - 1);
56 }
54 57
55 callback.Run(timezone.Pass(), server_error); 58 callback.Run(timezone.Pass(), server_error);
56 } 59 }
57 60
58 } // namespace chromeos 61 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/geolocation/simple_geolocation_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698