| 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 mojom::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( | 25   GeolocationServiceImpl( | 
| 27       mojo::InterfaceRequest<mojom::GeolocationService> request, | 26       mojo::InterfaceRequest<blink::mojom::GeolocationService> request, | 
| 28       GeolocationServiceContext* context, | 27       GeolocationServiceContext* context, | 
| 29       const base::Closure& update_callback); | 28       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. | 
| 40   void SetOverride(const Geoposition& position); | 39   void SetOverride(const Geoposition& position); | 
| 41   void ClearOverride(); | 40   void ClearOverride(); | 
| 42 | 41 | 
| 43  private: | 42  private: | 
| 44   typedef mojo::Callback<void(mojom::MojoGeopositionPtr)> PositionCallback; | 43   typedef mojo::Callback<void(blink::mojom::GeopositionPtr)> PositionCallback; | 
| 45 | 44 | 
| 46   // GeolocationService: | 45   // blink::mojom::GeolocationService: | 
| 47   void SetHighAccuracy(bool high_accuracy) override; | 46   void SetHighAccuracy(bool high_accuracy) override; | 
| 48   void QueryNextPosition(const PositionCallback& callback) override; | 47   void QueryNextPosition(const PositionCallback& callback) override; | 
| 49 | 48 | 
| 50   void OnConnectionError(); | 49   void OnConnectionError(); | 
| 51 | 50 | 
| 52   void OnLocationUpdate(const Geoposition& position); | 51   void OnLocationUpdate(const Geoposition& position); | 
| 53   void ReportCurrentPosition(); | 52   void ReportCurrentPosition(); | 
| 54 | 53 | 
| 55   // 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. | 
| 56   mojo::Binding<mojom::GeolocationService> binding_; | 55   mojo::Binding<blink::mojom::GeolocationService> binding_; | 
| 57 | 56 | 
| 58   // Owns this object. | 57   // Owns this object. | 
| 59   GeolocationServiceContext* context_; | 58   GeolocationServiceContext* context_; | 
| 60   scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; | 59   scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; | 
| 61 | 60 | 
| 62   // 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 | 
| 63   // position updates. | 62   // position updates. | 
| 64   base::Closure update_callback_; | 63   base::Closure update_callback_; | 
| 65 | 64 | 
| 66   // The callback passed to QueryNextPosition. | 65   // The callback passed to QueryNextPosition. | 
| 67   PositionCallback position_callback_; | 66   PositionCallback position_callback_; | 
| 68 | 67 | 
| 69   // Valid iff SetOverride() has been called and ClearOverride() has not | 68   // Valid iff SetOverride() has been called and ClearOverride() has not | 
| 70   // subsequently been called. | 69   // subsequently been called. | 
| 71   Geoposition position_override_; | 70   Geoposition position_override_; | 
| 72 | 71 | 
| 73   mojom::MojoGeoposition current_position_; | 72   blink::mojom::Geoposition current_position_; | 
| 74 | 73 | 
| 75   // Whether this instance is currently observing location updates with high | 74   // Whether this instance is currently observing location updates with high | 
| 76   // accuracy. | 75   // accuracy. | 
| 77   bool high_accuracy_; | 76   bool high_accuracy_; | 
| 78 | 77 | 
| 79   bool has_position_to_report_; | 78   bool has_position_to_report_; | 
| 80 | 79 | 
| 81   DISALLOW_COPY_AND_ASSIGN(GeolocationServiceImpl); | 80   DISALLOW_COPY_AND_ASSIGN(GeolocationServiceImpl); | 
| 82 }; | 81 }; | 
| 83 | 82 | 
| 84 }  // namespace content | 83 }  // namespace content | 
| 85 | 84 | 
| 86 #endif  // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ | 85 #endif  // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ | 
| OLD | NEW | 
|---|