| 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 DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ | 5 #ifndef DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ |
| 6 #define DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ | 6 #define DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "device/geolocation/geolocation_export.h" | 10 #include "device/geolocation/geolocation_export.h" |
| 11 #include "device/geolocation/public/interfaces/geolocation.mojom.h" | 11 #include "device/geolocation/public/interfaces/geolocation.mojom.h" |
| 12 | 12 |
| 13 namespace device { | 13 namespace device { |
| 14 | 14 |
| 15 class GeolocationServiceImpl; | 15 class GeolocationServiceImpl; |
| 16 struct Geoposition; | 16 struct Geoposition; |
| 17 | 17 |
| 18 // Provides information to a set of GeolocationServiceImpl instances that are | 18 // Provides information to a set of GeolocationServiceImpl instances that are |
| 19 // associated with a given context. Notably, allows pausing and resuming | 19 // associated with a given context. Notably, allows pausing and resuming |
| 20 // geolocation on these instances. | 20 // geolocation on these instances. |
| 21 class DEVICE_GEOLOCATION_EXPORT GeolocationServiceContext { | 21 class DEVICE_GEOLOCATION_EXPORT GeolocationServiceContext { |
| 22 public: | 22 public: |
| 23 GeolocationServiceContext(); | 23 GeolocationServiceContext(); |
| 24 virtual ~GeolocationServiceContext(); | 24 virtual ~GeolocationServiceContext(); |
| 25 | 25 |
| 26 // Creates a GeolocationServiceImpl that is weakly bound to |request|. | 26 // Creates a GeolocationServiceImpl that is weakly bound to |request|. |
| 27 // |update_callback| will be called when services send | 27 void CreateService(mojo::InterfaceRequest<mojom::GeolocationService> request); |
| 28 // location updates to their clients. | |
| 29 void CreateService(const base::Closure& update_callback, | |
| 30 mojo::InterfaceRequest<mojom::GeolocationService> request); | |
| 31 | 28 |
| 32 // Called when a service has a connection error. After this call, it is no | 29 // Called when a service has a connection error. After this call, it is no |
| 33 // longer safe to access |service|. | 30 // longer safe to access |service|. |
| 34 void ServiceHadConnectionError(GeolocationServiceImpl* service); | 31 void ServiceHadConnectionError(GeolocationServiceImpl* service); |
| 35 | 32 |
| 36 // Enables geolocation override. This method can be used to trigger possible | 33 // Enables geolocation override. This method can be used to trigger possible |
| 37 // location-specific behavior in a particular context. | 34 // location-specific behavior in a particular context. |
| 38 void SetOverride(std::unique_ptr<Geoposition> geoposition); | 35 void SetOverride(std::unique_ptr<Geoposition> geoposition); |
| 39 | 36 |
| 40 // Disables geolocation override. | 37 // Disables geolocation override. |
| 41 void ClearOverride(); | 38 void ClearOverride(); |
| 42 | 39 |
| 43 private: | 40 private: |
| 44 ScopedVector<GeolocationServiceImpl> services_; | 41 ScopedVector<GeolocationServiceImpl> services_; |
| 45 | 42 |
| 46 std::unique_ptr<Geoposition> geoposition_override_; | 43 std::unique_ptr<Geoposition> geoposition_override_; |
| 47 | 44 |
| 48 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceContext); | 45 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceContext); |
| 49 }; | 46 }; |
| 50 | 47 |
| 51 } // namespace device | 48 } // namespace device |
| 52 | 49 |
| 53 #endif // DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ | 50 #endif // DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_ |
| OLD | NEW |