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