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 GeolocationServiceContext; | |
16 | |
17 // Implements the GeolocationService Mojo interface. | |
18 class GeolocationServiceImpl : public mojo::InterfaceImpl<GeolocationService> { | |
19 public: | |
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; | |
25 | |
26 // Starts listening for updates. | |
27 void StartListeningForUpdates(); | |
28 | |
29 // Pauses and resumes sending updates to the client of this instance. | |
30 void PauseUpdates(); | |
31 void ResumeUpdates(); | |
32 | |
33 // Enables and disables geolocation override. | |
34 void SetOverride(const Geoposition& position); | |
35 void ClearOverride(); | |
36 | |
37 private: | |
38 // GeolocationService: | |
39 void SetHighAccuracy(bool high_accuracy) override; | |
40 | |
41 // mojo::InterfaceImpl: | |
42 void OnConnectionError() override; | |
43 | |
44 void OnLocationUpdate(const Geoposition& position); | |
45 | |
46 // Owns this object. | |
47 GeolocationServiceContext* context_; | |
48 scoped_ptr<GeolocationProvider::Subscription> geolocation_subscription_; | |
49 base::Closure update_callback_; | |
50 | |
51 // Valid iff SetOverride() has been called and ClearOverride() has not | |
52 // subsequently been called. | |
53 Geoposition position_override_; | |
54 | |
55 // Whether this instance is currently observing location updates with high | |
56 // accuracy. | |
57 bool high_accuracy_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceImpl); | |
60 }; | |
61 | |
62 } // namespace content | |
63 | |
64 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ | |
OLD | NEW |