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 23 matching lines...) Expand all Loading... |
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 private: | 43 private: |
| 44 friend class TestGeolocationAPIURLFetcherCallback; |
| 45 |
44 // Geolocation response callback. Deletes request from requests_. | 46 // Geolocation response callback. Deletes request from requests_. |
45 void OnGeolocationResponse( | 47 void OnGeolocationResponse( |
46 SimpleGeolocationRequest* request, | 48 SimpleGeolocationRequest* request, |
47 SimpleGeolocationRequest::ResponseCallback callback, | 49 SimpleGeolocationRequest::ResponseCallback callback, |
48 const Geoposition& geoposition, | 50 const Geoposition& geoposition, |
49 bool server_error, | 51 bool server_error, |
50 const base::TimeDelta elapsed); | 52 const base::TimeDelta elapsed); |
51 | 53 |
52 scoped_refptr<net::URLRequestContextGetter> url_context_getter_; | 54 scoped_refptr<net::URLRequestContextGetter> url_context_getter_; |
53 | 55 |
54 // URL of the Google Maps Geolocation API. | 56 // URL of the Google Maps Geolocation API. |
55 const GURL url_; | 57 const GURL url_; |
56 | 58 |
57 // Requests in progress. | 59 // Requests in progress. |
58 // SimpleGeolocationProvider owns all requests, so this vector is deleted on | 60 // SimpleGeolocationProvider owns all requests, so this vector is deleted on |
59 // destroy. | 61 // destroy. |
60 ScopedVector<SimpleGeolocationRequest> requests_; | 62 ScopedVector<SimpleGeolocationRequest> requests_; |
61 | 63 |
62 // Creation and destruction should happen on the same thread. | 64 // Creation and destruction should happen on the same thread. |
63 base::ThreadChecker thread_checker_; | 65 base::ThreadChecker thread_checker_; |
64 | 66 |
65 DISALLOW_COPY_AND_ASSIGN(SimpleGeolocationProvider); | 67 DISALLOW_COPY_AND_ASSIGN(SimpleGeolocationProvider); |
66 }; | 68 }; |
67 | 69 |
68 } // namespace chromeos | 70 } // namespace chromeos |
69 | 71 |
70 #endif // CHROME_BROWSER_CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_PROVIDER_H_ | 72 #endif // CHROME_BROWSER_CHROMEOS_GEOLOCATION_SIMPLE_GEOLOCATION_PROVIDER_H_ |
OLD | NEW |