OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "content/browser/geolocation/geolocation_provider_impl.h" |
| 7 #include "content/common/geolocation_service.mojom.h" |
| 8 |
| 9 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ |
| 10 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ |
| 11 |
| 12 namespace content { |
| 13 |
| 14 class GeolocationProvider; |
| 15 class GeolocationServiceImplContext; |
| 16 |
| 17 // Implements the GeolocationService Mojo interface. |
| 18 class GeolocationServiceImpl : public mojo::InterfaceImpl<GeolocationService> { |
| 19 public: |
| 20 // |context| is the geolocation context in which created services should |
| 21 // operate. |on_location_update_callback| will be called when services send |
| 22 // location updates to their clients. |
| 23 static void Create(GeolocationServiceImplContext* context, |
| 24 const base::Closure& on_location_update_callback, |
| 25 mojo::InterfaceRequest<GeolocationService> request); |
| 26 |
| 27 // Pauses and resumes sending updates to the client of this instance. |
| 28 void PauseUpdates(); |
| 29 void ResumeUpdates(); |
| 30 |
| 31 // Called when the geolocation context associated with this object is |
| 32 // destroyed. |
| 33 void ContextDestroyed(); |
| 34 |
| 35 private: |
| 36 GeolocationServiceImpl(GeolocationServiceImplContext* context, |
| 37 const base::Closure& on_location_update_callback); |
| 38 virtual ~GeolocationServiceImpl(); |
| 39 |
| 40 // GeolocationService: |
| 41 virtual void StartUpdating(bool high_accuracy) OVERRIDE; |
| 42 |
| 43 void StartListeningForUpdates(); |
| 44 void OnLocationUpdate(const Geoposition& position); |
| 45 |
| 46 // Will not necessarily outlive this object, but will call ContextDestroyed() |
| 47 // before going away. After a call to ContextDestroyed(), |context_| can no |
| 48 // longer safely be accessed. |
| 49 GeolocationServiceImplContext* context_; |
| 50 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; |
| 51 base::Closure on_location_update_callback_; |
| 52 |
| 53 // Whether this instance is currently observing location updates with high |
| 54 // accuracy. |
| 55 bool high_accuracy_; |
| 56 }; |
| 57 |
| 58 } // namespace content |
| 59 |
| 60 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ |
OLD | NEW |