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 // A location provider provides position information from a particular source | 5 // A location provider provides position information from a particular source |
6 // (GPS, network etc). | 6 // (GPS, network etc). |
7 // | 7 // |
8 // This file declares a base class to be used by all location providers. | 8 // This file declares a base class to be used by all location providers. |
9 // Primarily, this class declares interface methods to be implemented by | 9 // Primarily, this class declares interface methods to be implemented by |
10 // derived classes. | 10 // derived classes. |
11 | 11 |
12 #ifndef CONTENT_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ | 12 #ifndef CONTENT_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ |
13 #define CONTENT_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ | 13 #define CONTENT_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ |
14 #pragma once | 14 #pragma once |
15 | 15 |
16 #include <map> | 16 #include <map> |
17 | 17 |
18 #include "base/string16.h" | 18 #include "base/string16.h" |
19 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
21 | 21 |
22 struct Geoposition; | |
23 class GURL; | 22 class GURL; |
24 | 23 |
25 namespace content { | 24 namespace content { |
26 class AccessTokenStore; | 25 class AccessTokenStore; |
| 26 struct Geoposition; |
27 } | 27 } |
28 | 28 |
29 namespace net { | 29 namespace net { |
30 class URLRequestContextGetter; | 30 class URLRequestContextGetter; |
31 } | 31 } |
32 | 32 |
33 // The base class used by all location providers. | 33 // The base class used by all location providers. |
34 class CONTENT_EXPORT LocationProviderBase | 34 class CONTENT_EXPORT LocationProviderBase |
35 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | 35 : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
36 public: | 36 public: |
(...skipping 25 matching lines...) Expand all Loading... |
62 // It may block if a callback is in progress. | 62 // It may block if a callback is in progress. |
63 void UnregisterListener(ListenerInterface* listener); | 63 void UnregisterListener(ListenerInterface* listener); |
64 | 64 |
65 // Interface methods | 65 // Interface methods |
66 // StartProvider maybe called multiple times, e.g. to alter the | 66 // StartProvider maybe called multiple times, e.g. to alter the |
67 // |high_accuracy| setting. Returns false if a fatal error was encountered | 67 // |high_accuracy| setting. Returns false if a fatal error was encountered |
68 // which prevented the provider from starting. | 68 // which prevented the provider from starting. |
69 virtual bool StartProvider(bool high_accuracy) = 0; | 69 virtual bool StartProvider(bool high_accuracy) = 0; |
70 virtual void StopProvider() = 0; | 70 virtual void StopProvider() = 0; |
71 // Gets the current best position estimate. | 71 // Gets the current best position estimate. |
72 virtual void GetPosition(Geoposition* position) = 0; | 72 virtual void GetPosition(content::Geoposition* position) = 0; |
73 // Provides a hint to the provider that new location data is needed as soon | 73 // Provides a hint to the provider that new location data is needed as soon |
74 // as possible. Default implementation does nothing. | 74 // as possible. Default implementation does nothing. |
75 virtual void UpdatePosition() {} | 75 virtual void UpdatePosition() {} |
76 // Delegated to the provider by GeolocationArbitrator. See the corresponding | 76 // Delegated to the provider by GeolocationArbitrator. See the corresponding |
77 // method on that class for more details. | 77 // method on that class for more details. |
78 virtual void OnPermissionGranted() {} | 78 virtual void OnPermissionGranted() {} |
79 | 79 |
80 bool has_listeners() const; | 80 bool has_listeners() const; |
81 | 81 |
82 protected: | 82 protected: |
(...skipping 13 matching lines...) Expand all Loading... |
96 // Factory functions for the various types of location provider to abstract | 96 // Factory functions for the various types of location provider to abstract |
97 // over the platform-dependent implementations. | 97 // over the platform-dependent implementations. |
98 CONTENT_EXPORT LocationProviderBase* NewNetworkLocationProvider( | 98 CONTENT_EXPORT LocationProviderBase* NewNetworkLocationProvider( |
99 content::AccessTokenStore* access_token_store, | 99 content::AccessTokenStore* access_token_store, |
100 net::URLRequestContextGetter* context, | 100 net::URLRequestContextGetter* context, |
101 const GURL& url, | 101 const GURL& url, |
102 const string16& access_token); | 102 const string16& access_token); |
103 LocationProviderBase* NewSystemLocationProvider(); | 103 LocationProviderBase* NewSystemLocationProvider(); |
104 | 104 |
105 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ | 105 #endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_ |
OLD | NEW |