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_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 "content/public/browser/location_provider.h" | |
14 #include "content/public/common/geoposition.h" | |
15 | |
16 namespace blimp { | |
17 namespace client { | |
18 | |
19 // Client-side feature handling geolocation messages. | |
20 class GeolocationFeature : public BlimpMessageProcessor { | |
21 public: | |
22 GeolocationFeature( | |
23 std::unique_ptr<content::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 content::LocationProvider* location_provider, | |
38 const content::Geoposition& position); | |
39 | |
40 // Communicates to the client a change of interest level from the engine. | |
41 void OnGeolocationInterestUpdate( | |
42 GeolocationSetInterestLevelMessage::Level level); | |
43 | |
44 // Creates a GeolocationPositionMessage that reflects the given | |
45 // geoposition and sends it to the engine. | |
46 void SendGeolocationPositionMessage(const content::Geoposition& position); | |
47 | |
48 // Creates a GeolocationErrorMessage that reflects the error defined | |
49 // in the given geoposition and sends it. | |
50 void SendGeolocationErrorMessage( | |
51 const content::Geoposition::ErrorCode& error_code, | |
52 const std::string& error_message); | |
53 | |
54 std::unique_ptr<content::LocationProvider> location_provider_; | |
Kevin M
2016/07/28 21:32:42
Comment on the role of location_provider_?
CJ
2016/08/01 19:21:15
Done.
| |
55 | |
56 // Used to send BlimpMessage::GEOLOCATION message to the engine. | |
57 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(GeolocationFeature); | |
60 }; | |
61 | |
62 } // namespace client | |
63 } // namespace blimp | |
64 | |
65 #endif // BLIMP_CLIENT_FEATURE_GEOLOCATION_FEATURE_H_ | |
OLD | NEW |