| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "content/browser/geolocation/geolocation_provider_impl.h" | 6 #include "content/browser/geolocation/geolocation_provider_impl.h" |
| 7 #include "content/common/geolocation_service.mojom.h" | 7 #include "content/common/geolocation_service.mojom.h" |
| 8 #include "content/public/common/mojo_geoposition.mojom.h" | 8 #include "content/public/common/mojo_geoposition.mojom.h" |
| 9 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 9 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 10 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.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 GeolocationService { |
| 22 public mojo::ErrorHandler { | |
| 23 public: | 21 public: |
| 24 // |context| must outlive this object. |update_callback| will be called when | 22 // |context| must outlive this object. |update_callback| will be called when |
| 25 // 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 |
| 26 // is being used. | 24 // is being used. |
| 27 GeolocationServiceImpl(mojo::InterfaceRequest<GeolocationService> request, | 25 GeolocationServiceImpl(mojo::InterfaceRequest<GeolocationService> request, |
| 28 GeolocationServiceContext* context, | 26 GeolocationServiceContext* context, |
| 29 const base::Closure& update_callback); | 27 const base::Closure& update_callback); |
| 30 ~GeolocationServiceImpl() override; | 28 ~GeolocationServiceImpl() override; |
| 31 | 29 |
| 32 // Starts listening for updates. | 30 // Starts listening for updates. |
| 33 void StartListeningForUpdates(); | 31 void StartListeningForUpdates(); |
| 34 | 32 |
| 35 // Pauses and resumes sending updates to the client of this instance. | 33 // Pauses and resumes sending updates to the client of this instance. |
| 36 void PauseUpdates(); | 34 void PauseUpdates(); |
| 37 void ResumeUpdates(); | 35 void ResumeUpdates(); |
| 38 | 36 |
| 39 // Enables and disables geolocation override. | 37 // Enables and disables geolocation override. |
| 40 void SetOverride(const Geoposition& position); | 38 void SetOverride(const Geoposition& position); |
| 41 void ClearOverride(); | 39 void ClearOverride(); |
| 42 | 40 |
| 43 private: | 41 private: |
| 44 typedef mojo::Callback<void(MojoGeopositionPtr)> PositionCallback; | 42 typedef mojo::Callback<void(MojoGeopositionPtr)> PositionCallback; |
| 45 | 43 |
| 46 // GeolocationService: | 44 // GeolocationService: |
| 47 void SetHighAccuracy(bool high_accuracy) override; | 45 void SetHighAccuracy(bool high_accuracy) override; |
| 48 void QueryNextPosition(const PositionCallback& callback) override; | 46 void QueryNextPosition(const PositionCallback& callback) override; |
| 49 | 47 |
| 50 // mojo::ErrorHandler: | 48 void OnConnectionError(); |
| 51 void OnConnectionError() override; | |
| 52 | 49 |
| 53 void OnLocationUpdate(const Geoposition& position); | 50 void OnLocationUpdate(const Geoposition& position); |
| 54 void ReportCurrentPosition(); | 51 void ReportCurrentPosition(); |
| 55 | 52 |
| 56 // The binding between this object and the other end of the pipe. | 53 // The binding between this object and the other end of the pipe. |
| 57 mojo::Binding<GeolocationService> binding_; | 54 mojo::Binding<GeolocationService> binding_; |
| 58 | 55 |
| 59 // Owns this object. | 56 // Owns this object. |
| 60 GeolocationServiceContext* context_; | 57 GeolocationServiceContext* context_; |
| 61 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; | 58 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 78 bool high_accuracy_; | 75 bool high_accuracy_; |
| 79 | 76 |
| 80 bool has_position_to_report_; | 77 bool has_position_to_report_; |
| 81 | 78 |
| 82 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceImpl); | 79 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceImpl); |
| 83 }; | 80 }; |
| 84 | 81 |
| 85 } // namespace content | 82 } // namespace content |
| 86 | 83 |
| 87 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ | 84 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ |
| OLD | NEW |