| 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_H_ |
| 6 #define DEVICE_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ | 6 #define DEVICE_GEOLOCATION_LOCATION_ARBITRATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 LocationArbitrator : public LocationProvider { |
| 38 : public LocationProvider { | |
| 39 public: | 38 public: |
| 40 // Number of milliseconds newer a location provider has to be that it's worth | 39 // 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 | 40 // switching to this location provider on the basis of it being fresher |
| 42 // (regardles of relative accuracy). Public for tests. | 41 // (regardles of relative accuracy). Public for tests. |
| 43 static const int64_t kFixStaleTimeoutMilliseconds; | 42 static const int64_t kFixStaleTimeoutMilliseconds; |
| 44 | 43 |
| 45 explicit LocationArbitratorImpl(GeolocationDelegate* delegate); | 44 explicit LocationArbitrator(GeolocationDelegate* delegate); |
| 46 ~LocationArbitratorImpl() override; | 45 ~LocationArbitrator() override; |
| 47 | 46 |
| 48 static GURL DefaultNetworkProviderURL(); | 47 static GURL DefaultNetworkProviderURL(); |
| 49 bool HasPermissionBeenGrantedForTest() const; | 48 bool HasPermissionBeenGrantedForTest() const; |
| 50 | 49 |
| 51 // LocationProvider implementation. | 50 // LocationProvider implementation. |
| 52 void SetUpdateCallback( | 51 void SetUpdateCallback( |
| 53 const LocationProviderUpdateCallback& callback) override; | 52 const LocationProviderUpdateCallback& callback) override; |
| 54 bool StartProvider(bool enable_high_accuracy) override; | 53 bool StartProvider(bool enable_high_accuracy) override; |
| 55 void StopProvider() override; | 54 void StopProvider() override; |
| 56 const Geoposition& GetPosition() override; | 55 const Geoposition& GetPosition() override; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 bool enable_high_accuracy_; | 108 bool enable_high_accuracy_; |
| 110 // The provider which supplied the current |position_| | 109 // The provider which supplied the current |position_| |
| 111 const LocationProvider* position_provider_; | 110 const LocationProvider* position_provider_; |
| 112 bool is_permission_granted_; | 111 bool is_permission_granted_; |
| 113 // The current best estimate of our position. | 112 // The current best estimate of our position. |
| 114 Geoposition position_; | 113 Geoposition position_; |
| 115 | 114 |
| 116 // Tracks whether providers should be running. | 115 // Tracks whether providers should be running. |
| 117 bool is_running_; | 116 bool is_running_; |
| 118 | 117 |
| 119 DISALLOW_COPY_AND_ASSIGN(LocationArbitratorImpl); | 118 DISALLOW_COPY_AND_ASSIGN(LocationArbitrator); |
| 120 }; | 119 }; |
| 121 | 120 |
| 122 // Factory functions for the various types of location provider to abstract | 121 // Factory functions for the various types of location provider to abstract |
| 123 // over the platform-dependent implementations. | 122 // over the platform-dependent implementations. |
| 124 std::unique_ptr<LocationProvider> NewSystemLocationProvider(); | 123 std::unique_ptr<LocationProvider> NewSystemLocationProvider(); |
| 125 | 124 |
| 126 } // namespace device | 125 } // namespace device |
| 127 | 126 |
| 128 #endif // DEVICE_GEOLOCATION_LOCATION_ARBITRATOR_IMPL_H_ | 127 #endif // DEVICE_GEOLOCATION_LOCATION_ARBITRATOR_H_ |
| OLD | NEW |