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

Side by Side Diff: blimp/client/feature/geolocation_feature.h

Issue 2161223003: Adds GeolocationFeature for Blimp Geolocation project. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@engine_feature_prep
Patch Set: Addresses kmarshall's #8 comments and adds unittest 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BLIMP_CLIENT_FEATURE_GEOLOCATION_FEATURE_H_
6 #define BLIMP_CLIENT_FEATURE_GEOLOCATION_FEATURE_H_
7
8 #include <memory>
9
10 #include "blimp/common/proto/geolocation.pb.h"
11 #include "blimp/net/blimp_message_processor.h"
12 #include "content/public/common/geoposition.h"
13
14 namespace blimp {
15 namespace client {
16
17 // Client-side feature handling geolocation messages.
18 class GeolocationFeature : public BlimpMessageProcessor {
19 public:
20 // A delegate to be notified of specific geolocation events, such as
21 // change of interest in geolocation updates.
22 class GeolocationFeatureDelegate {
Wez 2016/07/22 01:35:08 Why does the GeolocationFeature need its own Deleg
CJ 2016/07/22 19:22:35 At this point in time it is not planned to work wi
Wez 2016/07/22 22:14:51 I would recommend having GeolocationFeature instan
23 public:
24 // Handles updates in accuracy level of the listen state.
25 virtual void OnGeolocationInterestUpdate(
26 GeolocationSetInterestLevelMessage::Level level) = 0;
27
28 // Called when a refresh in geolocation data is needed.
29 virtual void OnRequestRefresh() = 0;
30 };
31
32 GeolocationFeature();
33 ~GeolocationFeature() override;
34
35 // Sets the BlimpMessageProcessor that will be used to send
36 // BlimpMessage::GEOLOCATION messages to the engine.
37 void set_outgoing_message_processor(
38 std::unique_ptr<BlimpMessageProcessor> processor);
39
40 // Sets a GeolocationFeatureDelegate to be notified of all geolocation
41 // updates from the engine.
42 void SetDelegate(GeolocationFeatureDelegate* delegate);
Wez 2016/07/22 01:35:08 You're passing in a bare-pointer, so be clear abou
CJ 2016/07/22 19:22:35 Made it into a unique_ptr handled by the Geolocati
43
44 // Sends engine an update of the client's geoposition.
45 void OnLocationUpdate(const content::Geoposition& position);
46
47 // BlimpMessageProcessor implementation.
48 void ProcessMessage(std::unique_ptr<BlimpMessage> message,
49 const net::CompletionCallback& callback) override;
50
51 private:
52 // Creates a GeolocationPositionMessage that reflects the given
53 // geoposition and sends it to the engine.
54 void SendGeolocationPositionMessage(const content::Geoposition& position);
55
56 // Creates a GeolocationErrorMessage that reflects the error defined
57 // in the given geoposition and sends it.
58 void SendGeolocationErrorMessage(const content::Geoposition& position);
Wez 2016/07/22 01:35:08 nit: I'd suggest having this accept the error_code
CJ 2016/07/22 19:22:35 Done.
59
60 GeolocationFeatureDelegate* delegate_ = nullptr;
61
62 // Used to send BlimpMessage::GEOLOCATION message to the engine.
63 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_;
64
65 DISALLOW_COPY_AND_ASSIGN(GeolocationFeature);
66 };
67
68 } // namespace client
69 } // namespace blimp
70
71 #endif // BLIMP_CLIENT_FEATURE_GEOLOCATION_FEATURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698