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.
5 #include "base/memory/scoped_ptr.h"
6 #include "content/browser/geolocation/geolocation_provider_impl.h"
7 #include "content/common/geolocation_service.mojom.h"
9 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_
10 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_
14 class GeolocationProvider
;
15 class GeolocationServiceContext
;
17 // Implements the GeolocationService Mojo interface.
18 class GeolocationServiceImpl
: public mojo::InterfaceImpl
<GeolocationService
> {
20 // |context| must outlive this object. |update_callback| will be
21 // called when location updates are sent.
22 GeolocationServiceImpl(GeolocationServiceContext
* context
,
23 const base::Closure
& update_callback
);
24 ~GeolocationServiceImpl() override
;
26 // Starts listening for updates.
27 void StartListeningForUpdates();
29 // Pauses and resumes sending updates to the client of this instance.
33 // Enables and disables geolocation override.
34 void SetOverride(const Geoposition
& position
);
38 // GeolocationService:
39 void SetHighAccuracy(bool high_accuracy
) override
;
41 // mojo::InterfaceImpl:
42 void OnConnectionError() override
;
44 void OnLocationUpdate(const Geoposition
& position
);
47 GeolocationServiceContext
* context_
;
48 scoped_ptr
<GeolocationProvider::Subscription
> geolocation_subscription_
;
49 base::Closure update_callback_
;
51 // Valid iff SetOverride() has been called and ClearOverride() has not
52 // subsequently been called.
53 Geoposition position_override_
;
55 // Whether this instance is currently observing location updates with high
59 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceImpl
);
62 } // namespace content
64 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_