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..77a1c41c4e72473da89898064f7dcd090c47754b |
| --- /dev/null |
| +++ b/blimp/client/feature/geolocation_feature.h |
| @@ -0,0 +1,64 @@ |
| +// 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 { |
| + |
| +// Handles all incoming and outgoing protobu messages of type |
|
Kevin M
2016/07/20 17:30:15
typo
This is a literal description of how the cla
CJ
2016/07/20 23:22:10
Done.
|
| +// Geolocation. A delegate can be added to be notified of incoming 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 { |
| + public: |
| + virtual ~GeolocationFeatureDelegate() {} |
|
Kevin M
2016/07/20 17:30:16
Don't need a virtual dtor if the delegate object i
CJ
2016/07/20 23:22:10
Done.
|
| + virtual void OnGeolocationInterestUpdate( |
|
Kevin M
2016/07/20 17:30:16
Document each method and add newlines
CJ
2016/07/20 23:22:11
Done.
|
| + GeolocationSetInterestLevelMessage::Level level); |
|
Kevin M
2016/07/20 17:30:15
Make these methods pure virtual.
CJ
2016/07/20 23:22:10
Done.
|
| + virtual void OnRequestRefresh(); |
| + }; |
| + |
| + 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 |
|
Kevin M
2016/07/20 17:30:16
"messages" probably not so much... how about "even
CJ
2016/07/20 23:22:11
Done.
|
| + // messages from the engine. |
| + void SetDelegate(GeolocationFeatureDelegate* delegate); |
| + |
| + void OnLocationUpdate(const content::Geoposition& position); |
|
Kevin M
2016/07/20 17:30:15
Add comment
CJ
2016/07/20 23:22:10
Done.
|
| + |
| + // BlimpMessageProcessor implementation. |
| + void ProcessMessage(std::unique_ptr<BlimpMessage> message, |
| + const net::CompletionCallback& callback) override; |
| + |
| + private: |
| + void SendGeolocationPositionMessage(const content::Geoposition& position); |
|
Kevin M
2016/07/20 17:30:15
Add comment
CJ
2016/07/20 23:22:11
Done.
|
| + void SendGeolocationErrorMessage(const content::Geoposition& position); |
|
Kevin M
2016/07/20 17:30:16
Add comment
CJ
2016/07/20 23:22:10
Done.
|
| + |
| + GeolocationFeatureDelegate* delegate_; |
|
Kevin M
2016/07/20 17:30:16
= nullptr;
CJ
2016/07/20 23:22:11
Done.
|
| + |
| + // 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_ |