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

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: Merge with head 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"
9 #include "blimp/common/proto/geolocation.pb.h"
8 #include "content/public/browser/location_provider.h" 10 #include "content/public/browser/location_provider.h"
9 #include "content/public/common/geoposition.h" 11 #include "content/public/common/geoposition.h"
10 12
11 namespace blimp { 13 namespace blimp {
12 namespace engine { 14 namespace engine {
13 15
14 // Location provider for Blimp using the device's provider over the network. 16 // Location provider for Blimp using the device's provider over the network.
15 class BlimpLocationProvider : public content::LocationProvider { 17 class BlimpLocationProvider : public content::LocationProvider {
16 public: 18 public:
17 BlimpLocationProvider(); 19 // A delegate that handles outgoing geolocation messages.
Kevin M 2016/07/19 16:01:41 nit: messages are N/A at this layer
CJ 2016/07/19 20:35:58 Done.
20 class Delegate {
21 public:
22 virtual ~Delegate() {}
23
24 // Implements subset of LocationProvider's functions.
25 virtual void RequestAccuracy(
26 GeolocationSetInterestLevelMessage::Level level) = 0;
27 virtual void RequestRefresh() = 0;
28
29 virtual void SetUpdateCallback(
30 const base::Callback<void(const content::Geoposition&)>& callback) = 0;
Kevin M 2016/07/19 16:01:41 suggestion: create an alias for the callback type
CJ 2016/07/19 20:35:58 Done.
31 };
32
33 explicit BlimpLocationProvider(base::WeakPtr<Delegate> delegate);
18 ~BlimpLocationProvider() override; 34 ~BlimpLocationProvider() override;
19 35
20 // content::LocationProvider implementation. 36 // content::LocationProvider implementation.
21 bool StartProvider(bool high_accuracy) override; 37 bool StartProvider(bool high_accuracy) override;
22 void StopProvider() override; 38 void StopProvider() override;
23 void GetPosition(content::Geoposition* position) override; 39 void GetPosition(content::Geoposition* position) override;
24 void RequestRefresh() override; 40 void RequestRefresh() override;
25 void OnPermissionGranted() override; 41 void OnPermissionGranted() override;
26
27 private:
28 void NotifyCallback(const content::Geoposition& position);
29 void OnLocationResponse(const content::Geoposition& position);
30 void SetUpdateCallback( 42 void SetUpdateCallback(
31 const LocationProviderUpdateCallback& callback) override; 43 const LocationProviderUpdateCallback& callback) override;
32 44
33 LocationProviderUpdateCallback callback_; 45 private:
46 // This delegate handles a subset of the LocationProvider functionality.
47 // The lifetime of the delegate relative to the BlimpLocationProvider
Kevin M 2016/07/19 16:01:41 nit: I think the lifetime comment is already impli
CJ 2016/07/19 20:35:58 Done.
48 // is unknown.
49 base::WeakPtr<Delegate> delegate_;
34 50
51 // Needed for GetPosition(), which returns a cached position immediately.
35 content::Geoposition position_; 52 content::Geoposition position_;
Kevin M 2016/07/19 16:01:41 I think that we might be able to remove the commen
CJ 2016/07/19 20:35:58 Done.
36 53
37 DISALLOW_COPY_AND_ASSIGN(BlimpLocationProvider); 54 DISALLOW_COPY_AND_ASSIGN(BlimpLocationProvider);
38 }; 55 };
39 56
40 } // namespace engine 57 } // namespace engine
41 } // namespace blimp 58 } // namespace blimp
42 59
43 #endif // BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_ 60 #endif // BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698