| 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 #ifndef CHROME_BROWSER_CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_PROVIDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 virtual ~SimpleGeolocationProvider(); | 33 virtual ~SimpleGeolocationProvider(); |
| 34 | 34 |
| 35 // Initiates new request (See SimpleGeolocationRequest for parameters | 35 // Initiates new request (See SimpleGeolocationRequest for parameters |
| 36 // description.) | 36 // description.) |
| 37 void RequestGeolocation(base::TimeDelta timeout, | 37 void RequestGeolocation(base::TimeDelta timeout, |
| 38 SimpleGeolocationRequest::ResponseCallback callback); | 38 SimpleGeolocationRequest::ResponseCallback callback); |
| 39 | 39 |
| 40 // Returns default geolocation service URL. | 40 // Returns default geolocation service URL. |
| 41 static GURL DefaultGeolocationProviderURL(); | 41 static GURL DefaultGeolocationProviderURL(); |
| 42 | 42 |
| 43 ScopedVector<SimpleGeolocationRequest>& get_requests_for_testing() { |
| 44 return requests_; |
| 45 } |
| 46 |
| 43 private: | 47 private: |
| 44 // Geolocation response callback. Deletes request from requests_. | 48 // Geolocation response callback. Deletes request from requests_. |
| 45 void OnGeolocationResponse( | 49 void OnGeolocationResponse( |
| 46 SimpleGeolocationRequest* request, | 50 SimpleGeolocationRequest* request, |
| 47 SimpleGeolocationRequest::ResponseCallback callback, | 51 SimpleGeolocationRequest::ResponseCallback callback, |
| 48 const Geoposition& geoposition, | 52 const Geoposition& geoposition, |
| 49 bool server_error, | 53 bool server_error, |
| 50 const base::TimeDelta elapsed); | 54 const base::TimeDelta elapsed); |
| 51 | 55 |
| 52 scoped_refptr<net::URLRequestContextGetter> url_context_getter_; | 56 scoped_refptr<net::URLRequestContextGetter> url_context_getter_; |
| 53 | 57 |
| 54 // URL of the Google Maps Geolocation API. | 58 // URL of the Google Maps Geolocation API. |
| 55 const GURL url_; | 59 const GURL url_; |
| 56 | 60 |
| 57 // Requests in progress. | 61 // Requests in progress. |
| 58 // SimpleGeolocationProvider owns all requests, so this vector is deleted on | 62 // SimpleGeolocationProvider owns all requests, so this vector is deleted on |
| 59 // destroy. | 63 // destroy. |
| 60 ScopedVector<SimpleGeolocationRequest> requests_; | 64 ScopedVector<SimpleGeolocationRequest> requests_; |
| 61 | 65 |
| 62 // Creation and destruction should happen on the same thread. | 66 // Creation and destruction should happen on the same thread. |
| 63 base::ThreadChecker thread_checker_; | 67 base::ThreadChecker thread_checker_; |
| 64 | 68 |
| 65 DISALLOW_COPY_AND_ASSIGN(SimpleGeolocationProvider); | 69 DISALLOW_COPY_AND_ASSIGN(SimpleGeolocationProvider); |
| 66 }; | 70 }; |
| 67 | 71 |
| 68 } // namespace chromeos | 72 } // namespace chromeos |
| 69 | 73 |
| 70 #endif // CHROME_BROWSER_CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_PROVIDER_H_ | 74 #endif // CHROME_BROWSER_CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_PROVIDER_H_ |
| OLD | NEW |