Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: blimp/engine/feature/geolocation/blimp_location_provider.h

Issue 2091023006: Adds EngineGeolocationFeature for Blimp Geolocation project. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating repo to see if try is fixed Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
Wez 2016/07/12 21:35:13 This interface looks exactly like the LocationProv
CJ 2016/07/13 21:49:20 Done.
20 public:
21 virtual ~Delegate() {}
22
23 // Notifies the client that the is listening engine is listening for
24 // geoposition information with the given accuracy.
25 virtual void UpdateListenState(bool enable_high_accuracy) = 0;
26
27 // Notifies the client that the engine is no longer listening for
28 // updates.
29 virtual void StopListenState() = 0;
Wez 2016/07/12 21:35:13 This name is rather confusing; what does it mean t
CJ 2016/07/13 21:49:20 It's now changed to StopListener, as per the previ
Wez 2016/07/14 01:19:21 IIUC you're arguing that this allows you to isolat
CJ 2016/07/14 23:55:08 Done.
30
31 // Requests an updated geoposition from the client.
32 virtual void RequestRefresh() = 0;
33
34 virtual void SetUpdateCallback(
35 const base::Callback<void(const content::Geoposition&)>& callback) = 0;
36
37 virtual void NotifyCallback(const content::Geoposition& position) = 0;
Wez 2016/07/12 21:35:13 Why does the Delegate need a NotifyCallback() API?
CJ 2016/07/13 21:49:20 Done.
38 };
39
17 BlimpLocationProvider(); 40 BlimpLocationProvider();
18 ~BlimpLocationProvider() override; 41 ~BlimpLocationProvider() override;
19 42
43 void SetDelegate(base::WeakPtr<Delegate> delegate);
Wez 2016/07/12 21:35:13 This needs a comment to explain what the |delegate
CJ 2016/07/13 21:49:20 Tried to explain. Please tell me if I'm off.
Wez 2016/07/14 01:19:21 nit: Looks like you can move the |delegate| parame
CJ 2016/07/14 23:55:08 Done.
44
20 // content::LocationProvider implementation. 45 // content::LocationProvider implementation.
21 bool StartProvider(bool high_accuracy) override; 46 bool StartProvider(bool high_accuracy) override;
22 void StopProvider() override; 47 void StopProvider() override;
23 void GetPosition(content::Geoposition* position) override; 48 void GetPosition(content::Geoposition* position) override;
24 void RequestRefresh() override; 49 void RequestRefresh() override;
25 void OnPermissionGranted() override; 50 void OnPermissionGranted() override;
26
27 private:
28 void NotifyCallback(const content::Geoposition& position);
29 void OnLocationResponse(const content::Geoposition& position);
30 void SetUpdateCallback( 51 void SetUpdateCallback(
31 const LocationProviderUpdateCallback& callback) override; 52 const LocationProviderUpdateCallback& callback) override;
32 53
33 LocationProviderUpdateCallback callback_; 54 private:
55 base::WeakPtr<Delegate> delegate_ = nullptr;
Wez 2016/07/12 21:35:13 I'm surprised that this even compiles, since you'r
CJ 2016/07/13 21:49:20 Didn't know that. Removing nullptr.
34 56
35 content::Geoposition position_; 57 content::Geoposition position_;
Wez 2016/07/12 21:35:13 nit: Add a comment to explain why this is required
CJ 2016/07/13 21:49:20 Done.
36 58
37 DISALLOW_COPY_AND_ASSIGN(BlimpLocationProvider); 59 DISALLOW_COPY_AND_ASSIGN(BlimpLocationProvider);
38 }; 60 };
39 61
40 } // namespace engine 62 } // namespace engine
41 } // namespace blimp 63 } // namespace blimp
42 64
43 #endif // BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_ 65 #endif // BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698