Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_CORE_GEOLOCATION_GEOLOCATION_FEATURE_H_ | |
| 6 #define BLIMP_CLIENT_CORE_GEOLOCATION_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 explicit GeolocationFeature( | |
| 23 std::unique_ptr<device::LocationProvider> location_provider); | |
| 24 ~GeolocationFeature() override; | |
| 25 | |
| 26 // Sets the BlimpMessageProcessor that will be used to send | |
| 27 // BlimpMessage::GEOLOCATION messages to the engine. | |
| 28 void set_outgoing_message_processor( | |
| 29 std::unique_ptr<BlimpMessageProcessor> processor); | |
| 30 | |
| 31 // BlimpMessageProcessor implementation. | |
| 32 void ProcessMessage(std::unique_ptr<BlimpMessage> message, | |
| 33 const net::CompletionCallback& callback) override; | |
| 34 | |
| 35 private: | |
| 36 // Sends engine an update of the client's geoposition. | |
| 37 void OnLocationUpdate(const device::LocationProvider* location_provider, | |
| 38 const device::Geoposition& position); | |
| 39 | |
| 40 // Communicates to the client a change of interest level from the engine. | |
|
Wez
2016/08/19 18:50:25
nit: This wording is very similar to the preceding
CJ
2016/08/19 22:22:33
Done.
| |
| 41 void SetInterestLevel(GeolocationSetInterestLevelMessage::Level level); | |
| 42 | |
| 43 // Creates a GeolocationPositionMessage that reflects the given | |
| 44 // geoposition and sends it to the engine. | |
|
Wez
2016/08/19 18:50:25
nit: "Creates ... and sends ..." is redundant - su
CJ
2016/08/19 22:22:33
Done.
| |
| 45 void SendGeolocationPositionMessage(const device::Geoposition& position); | |
| 46 | |
| 47 // Creates a GeolocationErrorMessage that reflects the error defined | |
| 48 // in the given geoposition and sends it. | |
| 49 void SendGeolocationErrorMessage( | |
| 50 GeolocationErrorMessage::ErrorCode error_code, | |
| 51 const std::string& error_message); | |
| 52 | |
| 53 // Callback function when message finishes sending. | |
|
Wez
2016/08/19 18:50:25
nit: Grammar; I think you mean "Called when a mess
CJ
2016/08/19 22:22:33
Done.
| |
| 54 void OnSendComplete(int result); | |
| 55 | |
| 56 // Used to obtain the client's location. | |
| 57 std::unique_ptr<device::LocationProvider> location_provider_; | |
| 58 | |
| 59 // Used to send BlimpMessage::GEOLOCATION message to the engine. | |
| 60 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; | |
| 61 | |
| 62 // Run when message is finished sending. | |
|
Wez
2016/08/19 18:50:25
Not clear from the context who is sending the mess
CJ
2016/08/19 22:22:33
Good point. Not stored now.
| |
| 63 net::CompletionCallback completion_callback_; | |
| 64 | |
| 65 // True if a message is in the process of being sent. | |
| 66 bool sending_message_ = false; | |
|
Wez
2016/08/19 18:50:25
nit: Suggest am_sending_message_
In general you'l
CJ
2016/08/19 22:22:33
Cool thanks, fixed.
| |
| 67 | |
| 68 // True if location has been updated but a message cannot be sent at the | |
| 69 // moment. | |
| 70 bool need_to_send_message_ = false; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(GeolocationFeature); | |
| 73 }; | |
| 74 | |
| 75 } // namespace client | |
| 76 } // namespace blimp | |
| 77 | |
| 78 #endif // BLIMP_CLIENT_CORE_GEOLOCATION_GEOLOCATION_FEATURE_H_ | |
| OLD | NEW |