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 DEVICE_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ | 5 #ifndef DEVICE_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ |
6 #define DEVICE_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ | 6 #define DEVICE_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <memory> | |
Wez
2016/08/09 01:17:04
What's this extra include needed for?
CJ
2016/08/11 22:06:43
Lint complains without it. It's because we are usi
| |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
12 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
15 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
17 #include "device/geolocation/access_token_store.h" | 18 #include "device/geolocation/access_token_store.h" |
18 #include "device/geolocation/geolocation_export.h" | 19 #include "device/geolocation/geolocation_export.h" |
19 #include "device/geolocation/geolocation_provider.h" | 20 #include "device/geolocation/geolocation_provider.h" |
20 #include "device/geolocation/geoposition.h" | 21 #include "device/geolocation/geoposition.h" |
21 #include "device/geolocation/location_arbitrator.h" | |
22 #include "device/geolocation/location_provider.h" | 22 #include "device/geolocation/location_provider.h" |
23 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 class URLRequestContextGetter; | 26 class URLRequestContextGetter; |
27 } | 27 } |
28 | 28 |
29 namespace device { | 29 namespace device { |
30 class AccessTokenStore; | 30 class AccessTokenStore; |
31 class GeolocationDelegate; | 31 class GeolocationDelegate; |
32 class LocationProvider; | 32 class LocationProvider; |
33 | 33 |
34 // This class is responsible for handling updates from multiple underlying | 34 // This class is responsible for handling updates from multiple underlying |
35 // providers and resolving them to a single 'best' location fix at any given | 35 // providers and resolving them to a single 'best' location fix at any given |
36 // moment. | 36 // moment. |
37 class DEVICE_GEOLOCATION_EXPORT LocationArbitratorImpl | 37 class DEVICE_GEOLOCATION_EXPORT LocationArbitratorImpl |
38 : public LocationArbitrator { | 38 : public LocationProvider { |
39 public: | 39 public: |
40 // Number of milliseconds newer a location provider has to be that it's worth | 40 // Number of milliseconds newer a location provider has to be that it's worth |
41 // switching to this location provider on the basis of it being fresher | 41 // switching to this location provider on the basis of it being fresher |
42 // (regardles of relative accuracy). Public for tests. | 42 // (regardles of relative accuracy). Public for tests. |
43 static const int64_t kFixStaleTimeoutMilliseconds; | 43 static const int64_t kFixStaleTimeoutMilliseconds; |
44 | 44 |
45 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback; | 45 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback; |
46 | 46 |
47 LocationArbitratorImpl(const LocationUpdateCallback& callback, | 47 LocationArbitratorImpl(const LocationUpdateCallback& callback, |
48 GeolocationDelegate* delegate); | 48 GeolocationDelegate* delegate); |
49 ~LocationArbitratorImpl() override; | 49 ~LocationArbitratorImpl() override; |
50 | 50 |
51 static GURL DefaultNetworkProviderURL(); | 51 static GURL DefaultNetworkProviderURL(); |
52 | 52 |
53 // LocationArbitrator | 53 // LocationProvider |
Wez
2016/08/09 01:17:04
nit: "LocationProvider implementation."
CJ
2016/08/11 22:06:43
Done.
| |
54 void StartProviders(bool enable_high_accuracy) override; | 54 void SetUpdateCallback( |
55 void StopProviders() override; | 55 const LocationProviderUpdateCallback& callback) override; |
56 bool StartProvider(bool enable_high_accuracy) override; | |
57 void StopProvider() override; | |
58 void GetPosition(Geoposition* position) override; | |
59 void RequestRefresh() override; | |
56 void OnPermissionGranted() override; | 60 void OnPermissionGranted() override; |
57 bool HasPermissionBeenGranted() const override; | 61 |
62 bool HasPermissionBeenGranted() const; | |
Wez
2016/08/09 01:17:04
Is this only used in tests, as discussed? If so th
CJ
2016/08/11 22:06:43
Done. Question, does adding "ForTest" to the end h
Wez
2016/08/12 00:33:44
IIRC there is a Clang plugin that will complain if
| |
58 | 63 |
59 protected: | 64 protected: |
60 // These functions are useful for injection of dependencies in derived | 65 // These functions are useful for injection of dependencies in derived |
61 // testing classes. | 66 // testing classes. |
62 virtual scoped_refptr<AccessTokenStore> NewAccessTokenStore(); | 67 virtual scoped_refptr<AccessTokenStore> NewAccessTokenStore(); |
63 virtual std::unique_ptr<LocationProvider> NewNetworkLocationProvider( | 68 virtual std::unique_ptr<LocationProvider> NewNetworkLocationProvider( |
64 const scoped_refptr<AccessTokenStore>& access_token_store, | 69 const scoped_refptr<AccessTokenStore>& access_token_store, |
65 const scoped_refptr<net::URLRequestContextGetter>& context, | 70 const scoped_refptr<net::URLRequestContextGetter>& context, |
66 const GURL& url, | 71 const GURL& url, |
67 const base::string16& access_token); | 72 const base::string16& access_token); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 DISALLOW_COPY_AND_ASSIGN(LocationArbitratorImpl); | 125 DISALLOW_COPY_AND_ASSIGN(LocationArbitratorImpl); |
121 }; | 126 }; |
122 | 127 |
123 // Factory functions for the various types of location provider to abstract | 128 // Factory functions for the various types of location provider to abstract |
124 // over the platform-dependent implementations. | 129 // over the platform-dependent implementations. |
125 std::unique_ptr<LocationProvider> NewSystemLocationProvider(); | 130 std::unique_ptr<LocationProvider> NewSystemLocationProvider(); |
126 | 131 |
127 } // namespace device | 132 } // namespace device |
128 | 133 |
129 #endif // DEVICE_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ | 134 #endif // DEVICE_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ |
OLD | NEW |