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

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: Comment update 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 implements a subset of LocationProvider's functions.
20 class Delegate {
21 public:
22 using GeopositionReceivedCallback =
23 base::Callback<void(const content::Geoposition&)>;
24
25 virtual ~Delegate() {}
26
27 virtual void RequestAccuracy(
28 GeolocationSetInterestLevelMessage::Level level) = 0;
29 virtual void RequestRefresh() = 0;
30
Kevin M 2016/07/21 17:37:05 remove newline
CJ 2016/07/21 22:04:46 Done.
31 virtual void SetUpdateCallback(
32 const GeopositionReceivedCallback& callback) = 0;
33 };
34
35 explicit BlimpLocationProvider(base::WeakPtr<Delegate> delegate);
18 ~BlimpLocationProvider() override; 36 ~BlimpLocationProvider() override;
19 37
20 // content::LocationProvider implementation. 38 // content::LocationProvider implementation.
21 bool StartProvider(bool high_accuracy) override; 39 bool StartProvider(bool high_accuracy) override;
22 void StopProvider() override; 40 void StopProvider() override;
23 void GetPosition(content::Geoposition* position) override; 41 void GetPosition(content::Geoposition* position) override;
24 void RequestRefresh() override; 42 void RequestRefresh() override;
25 void OnPermissionGranted() override; 43 void OnPermissionGranted() override;
26
27 private:
28 void NotifyCallback(const content::Geoposition& position);
29 void OnLocationResponse(const content::Geoposition& position);
30 void SetUpdateCallback( 44 void SetUpdateCallback(
31 const LocationProviderUpdateCallback& callback) override; 45 const LocationProviderUpdateCallback& callback) override;
32 46
33 LocationProviderUpdateCallback callback_; 47 private:
48 // This delegate handles a subset of the LocationProvider functionality.
49 base::WeakPtr<Delegate> delegate_;
34 50
35 content::Geoposition position_; 51 content::Geoposition cached_position_;
52
53 // Indicates whether a successful StartProvider call has occured.
Wez 2016/07/22 01:18:58 nit: Suggest "True if a ..."
CJ 2016/07/22 20:03:30 Done.
54 bool is_started_;
36 55
37 DISALLOW_COPY_AND_ASSIGN(BlimpLocationProvider); 56 DISALLOW_COPY_AND_ASSIGN(BlimpLocationProvider);
38 }; 57 };
39 58
40 } // namespace engine 59 } // namespace engine
41 } // namespace blimp 60 } // namespace blimp
42 61
43 #endif // BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_ 62 #endif // BLIMP_ENGINE_FEATURE_GEOLOCATION_BLIMP_LOCATION_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698