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 "chrome/browser/chromeos/geolocation/simple_geolocation_provider.h" | 5 #include "chrome/browser/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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 SimpleGeolocationProvider::~SimpleGeolocationProvider() { | 29 SimpleGeolocationProvider::~SimpleGeolocationProvider() { |
30 DCHECK(thread_checker_.CalledOnValidThread()); | 30 DCHECK(thread_checker_.CalledOnValidThread()); |
31 } | 31 } |
32 | 32 |
33 void SimpleGeolocationProvider::RequestGeolocation( | 33 void SimpleGeolocationProvider::RequestGeolocation( |
34 base::TimeDelta timeout, | 34 base::TimeDelta timeout, |
35 SimpleGeolocationRequest::ResponseCallback callback) { | 35 SimpleGeolocationRequest::ResponseCallback callback) { |
36 DCHECK(thread_checker_.CalledOnValidThread()); | 36 DCHECK(thread_checker_.CalledOnValidThread()); |
37 SimpleGeolocationRequest* request( | 37 SimpleGeolocationRequest* request( |
38 new SimpleGeolocationRequest(url_context_getter_, url_, timeout)); | 38 new SimpleGeolocationRequest(url_context_getter_.get(), url_, timeout)); |
39 requests_.push_back(request); | 39 requests_.push_back(request); |
40 | 40 |
41 // SimpleGeolocationProvider owns all requests. It is safe to pass unretained | 41 // SimpleGeolocationProvider owns all requests. It is safe to pass unretained |
42 // "this" because destruction of SimpleGeolocationProvider cancels all | 42 // "this" because destruction of SimpleGeolocationProvider cancels all |
43 // requests. | 43 // requests. |
44 SimpleGeolocationRequest::ResponseCallback callback_tmp( | 44 SimpleGeolocationRequest::ResponseCallback callback_tmp( |
45 base::Bind(&SimpleGeolocationProvider::OnGeolocationResponse, | 45 base::Bind(&SimpleGeolocationProvider::OnGeolocationResponse, |
46 base::Unretained(this), | 46 base::Unretained(this), |
47 request, | 47 request, |
48 callback)); | 48 callback)); |
(...skipping 15 matching lines...) Expand all Loading... |
64 | 64 |
65 callback.Run(geoposition, server_error, elapsed); | 65 callback.Run(geoposition, server_error, elapsed); |
66 | 66 |
67 ScopedVector<SimpleGeolocationRequest>::iterator new_end = | 67 ScopedVector<SimpleGeolocationRequest>::iterator new_end = |
68 std::remove(requests_.begin(), requests_.end(), request); | 68 std::remove(requests_.begin(), requests_.end(), request); |
69 DCHECK_EQ(std::distance(new_end, requests_.end()), 1); | 69 DCHECK_EQ(std::distance(new_end, requests_.end()), 1); |
70 requests_.erase(new_end, requests_.end()); | 70 requests_.erase(new_end, requests_.end()); |
71 } | 71 } |
72 | 72 |
73 } // namespace chromeos | 73 } // namespace chromeos |
OLD | NEW |