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