Chromium Code Reviews| Index: blimp/client/feature/geolocation_feature.h |
| diff --git a/blimp/client/feature/geolocation_feature.h b/blimp/client/feature/geolocation_feature.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0c5fa17c3d6bab738594bd880b1c607ce6c75e6a |
| --- /dev/null |
| +++ b/blimp/client/feature/geolocation_feature.h |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BLIMP_CLIENT_FEATURE_GEOLOCATION_FEATURE_H_ |
| +#define BLIMP_CLIENT_FEATURE_GEOLOCATION_FEATURE_H_ |
| + |
| +#include <memory> |
| + |
| +#include "blimp/common/proto/geolocation.pb.h" |
| +#include "blimp/net/blimp_message_processor.h" |
| +#include "content/public/common/geoposition.h" |
| + |
| +namespace blimp { |
| +namespace client { |
| + |
| +// Client-side feature handling geolocation messages. |
| +class GeolocationFeature : public BlimpMessageProcessor { |
| + public: |
| + // A delegate to be notified of specific geolocation events, such as |
| + // change of interest in geolocation updates. |
| + 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
|
| + public: |
| + // Handles updates in accuracy level of the listen state. |
| + virtual void OnGeolocationInterestUpdate( |
| + GeolocationSetInterestLevelMessage::Level level) = 0; |
| + |
| + // Called when a refresh in geolocation data is needed. |
| + virtual void OnRequestRefresh() = 0; |
| + }; |
| + |
| + GeolocationFeature(); |
| + ~GeolocationFeature() override; |
| + |
| + // Sets the BlimpMessageProcessor that will be used to send |
| + // BlimpMessage::GEOLOCATION messages to the engine. |
| + void set_outgoing_message_processor( |
| + std::unique_ptr<BlimpMessageProcessor> processor); |
| + |
| + // Sets a GeolocationFeatureDelegate to be notified of all geolocation |
| + // updates from the engine. |
| + 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
|
| + |
| + // Sends engine an update of the client's geoposition. |
| + void OnLocationUpdate(const content::Geoposition& position); |
| + |
| + // BlimpMessageProcessor implementation. |
| + void ProcessMessage(std::unique_ptr<BlimpMessage> message, |
| + const net::CompletionCallback& callback) override; |
| + |
| + private: |
| + // Creates a GeolocationPositionMessage that reflects the given |
| + // geoposition and sends it to the engine. |
| + void SendGeolocationPositionMessage(const content::Geoposition& position); |
| + |
| + // Creates a GeolocationErrorMessage that reflects the error defined |
| + // in the given geoposition and sends it. |
| + 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.
|
| + |
| + GeolocationFeatureDelegate* delegate_ = nullptr; |
| + |
| + // Used to send BlimpMessage::GEOLOCATION message to the engine. |
| + std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GeolocationFeature); |
| +}; |
| + |
| +} // namespace client |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_CLIENT_FEATURE_GEOLOCATION_FEATURE_H_ |