OLD | NEW |
---|---|
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 #ifndef BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_ | 5 #ifndef BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_ |
6 #define BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_ | 6 #define BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | |
8 #include "content/public/browser/location_provider.h" | 9 #include "content/public/browser/location_provider.h" |
9 #include "content/public/common/geoposition.h" | 10 #include "content/public/common/geoposition.h" |
10 | 11 |
11 namespace blimp { | 12 namespace blimp { |
12 namespace engine { | 13 namespace engine { |
13 | 14 |
14 // Location provider for Blimp using the device's provider over the network. | 15 // Location provider for Blimp using the device's provider over the network. |
15 class BlimpLocationProvider : public content::LocationProvider { | 16 class BlimpLocationProvider : public content::LocationProvider { |
16 public: | 17 public: |
18 // A delegate that handles outgoing geolocation messages. | |
19 class Delegate { | |
20 public: | |
21 virtual ~Delegate() {} | |
22 | |
23 // Implments subset of LocationProvider's functions. | |
Wez
2016/07/14 01:19:22
typo: Implements.
CJ
2016/07/14 23:55:09
Done.
| |
24 virtual void StartProvider(bool enable_high_accuracy) = 0; | |
25 virtual void StopProvider() = 0; | |
26 virtual void RequestRefresh() = 0; | |
27 | |
28 virtual void SetUpdateCallback( | |
29 const base::Callback<void(const content::Geoposition&)>& callback) = 0; | |
30 }; | |
31 | |
17 BlimpLocationProvider(); | 32 BlimpLocationProvider(); |
18 ~BlimpLocationProvider() override; | 33 ~BlimpLocationProvider() override; |
19 | 34 |
35 void SetDelegate(base::WeakPtr<Delegate> delegate); | |
36 | |
20 // content::LocationProvider implementation. | 37 // content::LocationProvider implementation. |
21 bool StartProvider(bool high_accuracy) override; | 38 bool StartProvider(bool high_accuracy) override; |
22 void StopProvider() override; | 39 void StopProvider() override; |
23 void GetPosition(content::Geoposition* position) override; | 40 void GetPosition(content::Geoposition* position) override; |
24 void RequestRefresh() override; | 41 void RequestRefresh() override; |
25 void OnPermissionGranted() override; | 42 void OnPermissionGranted() override; |
26 | |
27 private: | |
28 void NotifyCallback(const content::Geoposition& position); | |
29 void OnLocationResponse(const content::Geoposition& position); | |
30 void SetUpdateCallback( | 43 void SetUpdateCallback( |
31 const LocationProviderUpdateCallback& callback) override; | 44 const LocationProviderUpdateCallback& callback) override; |
32 | 45 |
33 LocationProviderUpdateCallback callback_; | 46 private: |
47 // This delegate handles a subset of the LocationProvider functionality. | |
48 // The lifetime of the delegate relative to the BlimpLocationProvider | |
49 // is unknown. | |
50 base::WeakPtr<Delegate> delegate_; | |
34 | 51 |
52 // Needed for GetPosition(), which returns a cached position immediately. | |
35 content::Geoposition position_; | 53 content::Geoposition position_; |
36 | 54 |
37 DISALLOW_COPY_AND_ASSIGN(BlimpLocationProvider); | 55 DISALLOW_COPY_AND_ASSIGN(BlimpLocationProvider); |
38 }; | 56 }; |
39 | 57 |
40 } // namespace engine | 58 } // namespace engine |
41 } // namespace blimp | 59 } // namespace blimp |
42 | 60 |
43 #endif // BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_ | 61 #endif // BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_ |
OLD | NEW |