| 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 #include <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "device/geolocation/geolocation_provider_impl.h" | 8 #include "device/geolocation/geolocation_provider_impl.h" |
| 9 #include "device/geolocation/public/interfaces/geolocation.mojom.h" | 9 #include "device/geolocation/public/interfaces/geolocation.mojom.h" |
| 10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| 11 | 11 |
| 12 #ifndef DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ | 12 #ifndef DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ |
| 13 #define DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ | 13 #define DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ |
| 14 | 14 |
| 15 namespace device { | 15 namespace device { |
| 16 | 16 |
| 17 class GeolocationProvider; | 17 class GeolocationProvider; |
| 18 class GeolocationServiceContext; | 18 class GeolocationServiceContext; |
| 19 | 19 |
| 20 // Implements the GeolocationService Mojo interface. | 20 // Implements the GeolocationService Mojo interface. |
| 21 class GeolocationServiceImpl : public mojom::GeolocationService { | 21 class GeolocationServiceImpl : public mojom::GeolocationService { |
| 22 public: | 22 public: |
| 23 // |context| must outlive this object. |update_callback| will be called when | 23 // |context| must outlive this object. |update_callback| will be called when |
| 24 // location updates are sent, allowing the client to know when the service | 24 // location updates are sent, allowing the client to know when the service |
| 25 // is being used. | 25 // is being used. |
| 26 GeolocationServiceImpl( | 26 GeolocationServiceImpl( |
| 27 mojo::InterfaceRequest<mojom::GeolocationService> request, | 27 mojo::InterfaceRequest<mojom::GeolocationService> request, |
| 28 GeolocationServiceContext* context, | 28 GeolocationServiceContext* context); |
| 29 const base::Closure& update_callback); | |
| 30 ~GeolocationServiceImpl() override; | 29 ~GeolocationServiceImpl() override; |
| 31 | 30 |
| 32 // Starts listening for updates. | 31 // Starts listening for updates. |
| 33 void StartListeningForUpdates(); | 32 void StartListeningForUpdates(); |
| 34 | 33 |
| 35 // Pauses and resumes sending updates to the client of this instance. | 34 // Pauses and resumes sending updates to the client of this instance. |
| 36 void PauseUpdates(); | 35 void PauseUpdates(); |
| 37 void ResumeUpdates(); | 36 void ResumeUpdates(); |
| 38 | 37 |
| 39 // Enables and disables geolocation override. | 38 // Enables and disables geolocation override. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 50 void OnLocationUpdate(const Geoposition& position); | 49 void OnLocationUpdate(const Geoposition& position); |
| 51 void ReportCurrentPosition(); | 50 void ReportCurrentPosition(); |
| 52 | 51 |
| 53 // The binding between this object and the other end of the pipe. | 52 // The binding between this object and the other end of the pipe. |
| 54 mojo::Binding<mojom::GeolocationService> binding_; | 53 mojo::Binding<mojom::GeolocationService> binding_; |
| 55 | 54 |
| 56 // Owns this object. | 55 // Owns this object. |
| 57 GeolocationServiceContext* context_; | 56 GeolocationServiceContext* context_; |
| 58 std::unique_ptr<GeolocationProvider::Subscription> geolocation_subscription_; | 57 std::unique_ptr<GeolocationProvider::Subscription> geolocation_subscription_; |
| 59 | 58 |
| 60 // Callback that allows the instantiator of this class to be notified on | |
| 61 // position updates. | |
| 62 base::Closure update_callback_; | |
| 63 | |
| 64 // The callback passed to QueryNextPosition. | 59 // The callback passed to QueryNextPosition. |
| 65 QueryNextPositionCallback position_callback_; | 60 QueryNextPositionCallback position_callback_; |
| 66 | 61 |
| 67 // Valid iff SetOverride() has been called and ClearOverride() has not | 62 // Valid iff SetOverride() has been called and ClearOverride() has not |
| 68 // subsequently been called. | 63 // subsequently been called. |
| 69 Geoposition position_override_; | 64 Geoposition position_override_; |
| 70 | 65 |
| 71 mojom::Geoposition current_position_; | 66 mojom::Geoposition current_position_; |
| 72 | 67 |
| 73 // Whether this instance is currently observing location updates with high | 68 // Whether this instance is currently observing location updates with high |
| 74 // accuracy. | 69 // accuracy. |
| 75 bool high_accuracy_; | 70 bool high_accuracy_; |
| 76 | 71 |
| 77 bool has_position_to_report_; | 72 bool has_position_to_report_; |
| 78 | 73 |
| 79 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceImpl); | 74 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceImpl); |
| 80 }; | 75 }; |
| 81 | 76 |
| 82 } // namespace device | 77 } // namespace device |
| 83 | 78 |
| 84 #endif // DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ | 79 #endif // DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ |
| OLD | NEW |