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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "content/browser/geolocation/geolocation_provider_impl.h" | 8 #include "content/browser/geolocation/geolocation_provider_impl.h" |
9 #include "mojo/public/cpp/bindings/binding.h" | 9 #include "mojo/public/cpp/bindings/binding.h" |
10 #include "third_party/WebKit/public/platform/modules/geolocation/geolocation.moj
om.h" | 10 #include "third_party/WebKit/public/platform/modules/geolocation/geolocation.moj
om.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 // Pauses and resumes sending updates to the client of this instance. | 35 // Pauses and resumes sending updates to the client of this instance. |
36 void PauseUpdates(); | 36 void PauseUpdates(); |
37 void ResumeUpdates(); | 37 void ResumeUpdates(); |
38 | 38 |
39 // Enables and disables geolocation override. | 39 // Enables and disables geolocation override. |
40 void SetOverride(const Geoposition& position); | 40 void SetOverride(const Geoposition& position); |
41 void ClearOverride(); | 41 void ClearOverride(); |
42 | 42 |
43 private: | 43 private: |
| 44 typedef mojo::Callback<void(blink::mojom::GeopositionPtr)> PositionCallback; |
| 45 |
44 // blink::mojom::GeolocationService: | 46 // blink::mojom::GeolocationService: |
45 void SetHighAccuracy(bool high_accuracy) override; | 47 void SetHighAccuracy(bool high_accuracy) override; |
46 void QueryNextPosition(const QueryNextPositionCallback& callback) override; | 48 void QueryNextPosition(const PositionCallback& callback) override; |
47 | 49 |
48 void OnConnectionError(); | 50 void OnConnectionError(); |
49 | 51 |
50 void OnLocationUpdate(const Geoposition& position); | 52 void OnLocationUpdate(const Geoposition& position); |
51 void ReportCurrentPosition(); | 53 void ReportCurrentPosition(); |
52 | 54 |
53 // The binding between this object and the other end of the pipe. | 55 // The binding between this object and the other end of the pipe. |
54 mojo::Binding<blink::mojom::GeolocationService> binding_; | 56 mojo::Binding<blink::mojom::GeolocationService> binding_; |
55 | 57 |
56 // Owns this object. | 58 // Owns this object. |
57 GeolocationServiceContext* context_; | 59 GeolocationServiceContext* context_; |
58 std::unique_ptr<GeolocationProvider::Subscription> geolocation_subscription_; | 60 std::unique_ptr<GeolocationProvider::Subscription> geolocation_subscription_; |
59 | 61 |
60 // Callback that allows the instantiator of this class to be notified on | 62 // Callback that allows the instantiator of this class to be notified on |
61 // position updates. | 63 // position updates. |
62 base::Closure update_callback_; | 64 base::Closure update_callback_; |
63 | 65 |
64 // The callback passed to QueryNextPosition. | 66 // The callback passed to QueryNextPosition. |
65 QueryNextPositionCallback position_callback_; | 67 PositionCallback position_callback_; |
66 | 68 |
67 // Valid iff SetOverride() has been called and ClearOverride() has not | 69 // Valid iff SetOverride() has been called and ClearOverride() has not |
68 // subsequently been called. | 70 // subsequently been called. |
69 Geoposition position_override_; | 71 Geoposition position_override_; |
70 | 72 |
71 blink::mojom::Geoposition current_position_; | 73 blink::mojom::Geoposition current_position_; |
72 | 74 |
73 // Whether this instance is currently observing location updates with high | 75 // Whether this instance is currently observing location updates with high |
74 // accuracy. | 76 // accuracy. |
75 bool high_accuracy_; | 77 bool high_accuracy_; |
76 | 78 |
77 bool has_position_to_report_; | 79 bool has_position_to_report_; |
78 | 80 |
79 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceImpl); | 81 DISALLOW_COPY_AND_ASSIGN(GeolocationServiceImpl); |
80 }; | 82 }; |
81 | 83 |
82 } // namespace content | 84 } // namespace content |
83 | 85 |
84 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ | 86 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_SERVICE_IMPL_H_ |
OLD | NEW |