OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ | 5 #ifndef DEVICE_GEOLOCATION_GEOLOCATION_PROVIDER_H_ |
6 #define CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ | 6 #define DEVICE_GEOLOCATION_GEOLOCATION_PROVIDER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback_list.h" | 10 #include "base/callback_list.h" |
11 #include "content/common/content_export.h" | 11 #include "device/geolocation/geolocation_export.h" |
12 | 12 |
13 namespace content { | 13 namespace device { |
14 class GeolocationDelegate; | 14 class GeolocationDelegate; |
15 struct Geoposition; | 15 struct Geoposition; |
16 | 16 |
17 // This is the main API to the geolocation subsystem. The application will hold | 17 // This is the main API to the geolocation subsystem. The application will hold |
18 // a single instance of this class and can register multiple clients to be | 18 // a single instance of this class and can register multiple clients to be |
19 // notified of location changes: | 19 // notified of location changes: |
20 // * Callbacks are registered by AddLocationUpdateCallback() and will keep | 20 // * Callbacks are registered by AddLocationUpdateCallback() and will keep |
21 // receiving updates until the returned subscription object is destructed. | 21 // receiving updates until the returned subscription object is destructed. |
22 // The application must instantiate the GeolocationProvider on the UI thread and | 22 // The application must instantiate the GeolocationProvider on the UI thread and |
23 // must communicate with it on the same thread. | 23 // must communicate with it on the same thread. |
24 // The underlying location arbitrator will only be enabled whilst there is at | 24 // The underlying location arbitrator will only be enabled whilst there is at |
25 // least one registered observer or pending callback (and only after | 25 // least one registered observer or pending callback (and only after |
26 // UserDidOptIntoLocationServices). The arbitrator and the location providers it | 26 // UserDidOptIntoLocationServices). The arbitrator and the location providers it |
27 // uses run on a separate Geolocation thread. | 27 // uses run on a separate Geolocation thread. |
28 class GeolocationProvider { | 28 class GeolocationProvider { |
29 public: | 29 public: |
30 CONTENT_EXPORT static GeolocationProvider* GetInstance(); | 30 DEVICE_GEOLOCATION_EXPORT static GeolocationProvider* GetInstance(); |
31 | 31 |
32 // Optional: provide a Delegate to override typical services. | 32 // Optional: provide a Delegate to override typical services. |
33 CONTENT_EXPORT static void SetGeolocationDelegate( | 33 DEVICE_GEOLOCATION_EXPORT static void SetGeolocationDelegate( |
34 GeolocationDelegate* delegate); | 34 GeolocationDelegate* delegate); |
35 | 35 |
36 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback; | 36 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback; |
37 typedef base::CallbackList<void(const Geoposition&)>::Subscription | 37 typedef base::CallbackList<void(const Geoposition&)>::Subscription |
38 Subscription; | 38 Subscription; |
39 | 39 |
40 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for | 40 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for |
41 // this particular observer, however the observer could receive updates for | 41 // this particular observer, however the observer could receive updates for |
42 // best available locations from any active provider whilst it is registered. | 42 // best available locations from any active provider whilst it is registered. |
43 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback( | 43 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback( |
(...skipping 15 matching lines...) Expand all Loading... |
59 // Do not use this function in unit tests. The function instantiates the | 59 // Do not use this function in unit tests. The function instantiates the |
60 // singleton geolocation stack in the background and manipulates it to report | 60 // singleton geolocation stack in the background and manipulates it to report |
61 // a fake location. Neither step can be undone, breaking unit test isolation | 61 // a fake location. Neither step can be undone, breaking unit test isolation |
62 // (crbug.com/125931). | 62 // (crbug.com/125931). |
63 virtual void OverrideLocationForTesting(const Geoposition& position) = 0; | 63 virtual void OverrideLocationForTesting(const Geoposition& position) = 0; |
64 | 64 |
65 protected: | 65 protected: |
66 virtual~GeolocationProvider() {} | 66 virtual~GeolocationProvider() {} |
67 }; | 67 }; |
68 | 68 |
69 } // namespace content | 69 } // namespace device |
70 | 70 |
71 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ | 71 #endif // DEVICE_GEOLOCATION_GEOLOCATION_PROVIDER_H_ |
OLD | NEW |