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

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: Makes UnexpectedMessage test work outside of debug Created 4 years, 4 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 #include <string>
10
11 #include "blimp/common/proto/geolocation.pb.h"
12 #include "blimp/net/blimp_message_processor.h"
13 #include "device/geolocation/geoposition.h"
14 #include "device/geolocation/location_provider.h"
15
16 namespace blimp {
17 namespace client {
18
19 // Client-side feature handling geolocation messages.
20 class GeolocationFeature : public BlimpMessageProcessor {
21 public:
22 // |location_provider| will be the only LocationProvider the
Kevin M 2016/08/15 20:35:40 Nit: I think this is already implied by the fact t
CJ 2016/08/15 21:59:32 Done.
23 // GeolocationFeature will gather information from.
24 explicit GeolocationFeature(
25 std::unique_ptr<device::LocationProvider> location_provider);
26 ~GeolocationFeature() override;
27
28 // Sets the BlimpMessageProcessor that will be used to send
29 // BlimpMessage::GEOLOCATION messages to the engine.
30 void set_outgoing_message_processor(
31 std::unique_ptr<BlimpMessageProcessor> processor);
32
33 // BlimpMessageProcessor implementation.
34 void ProcessMessage(std::unique_ptr<BlimpMessage> message,
35 const net::CompletionCallback& callback) override;
36
37 private:
38 // Sends engine an update of the client's geoposition.
39 void OnLocationUpdate(const device::LocationProvider* location_provider,
40 const device::Geoposition& position);
41
42 // Communicates to the client a change of interest level from the engine.
43 void SetInterestLevel(GeolocationSetInterestLevelMessage::Level level);
44
45 // Creates a GeolocationPositionMessage that reflects the given
46 // geoposition and sends it to the engine.
47 void SendGeolocationPositionMessage(const device::Geoposition& position);
48
49 // Creates a GeolocationErrorMessage that reflects the error defined
50 // in the given geoposition and sends it.
51 void SendGeolocationErrorMessage(
52 const GeolocationErrorMessage::ErrorCode& error_code,
Kevin M 2016/08/15 20:35:40 ErrorCode is a POD type, so should be passed as-is
CJ 2016/08/15 21:59:32 POD?
53 const std::string& error_message);
54
55 // Callback function when message finishes sending.
56 void OnSendComplete(int result);
57
58 // Used to obtain the client's location.
59 std::unique_ptr<device::LocationProvider> location_provider_;
60
61 // Used to send BlimpMessage::GEOLOCATION message to the engine.
62 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_;
63
64 // Run when message is finished sending.
65 net::CompletionCallback completion_callback_;
66
67 // True if a message is not in the process of being sent.
Kevin M 2016/08/15 20:35:40 I think the meaning of this variable, and how it i
CJ 2016/08/15 21:59:32 Done.
68 bool can_send_message_ = true;
69
70 DISALLOW_COPY_AND_ASSIGN(GeolocationFeature);
71 };
72
73 } // namespace client
74 } // namespace blimp
75
76 #endif // BLIMP_CLIENT_FEATURE_GEOLOCATION_FEATURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698