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..e8916ea7e5662031d1595db9f15fb5e4f44103d4 |
| --- /dev/null |
| +++ b/blimp/client/feature/geolocation_feature.h |
| @@ -0,0 +1,76 @@ |
| +// 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 <string> |
| + |
| +#include "blimp/common/proto/geolocation.pb.h" |
| +#include "blimp/net/blimp_message_processor.h" |
| +#include "device/geolocation/geoposition.h" |
| +#include "device/geolocation/location_provider.h" |
| + |
| +namespace blimp { |
| +namespace client { |
| + |
| +// Client-side feature handling geolocation messages. |
| +class GeolocationFeature : public BlimpMessageProcessor { |
| + public: |
| + // |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.
|
| + // GeolocationFeature will gather information from. |
| + explicit GeolocationFeature( |
| + std::unique_ptr<device::LocationProvider> location_provider); |
| + ~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); |
| + |
| + // BlimpMessageProcessor implementation. |
| + void ProcessMessage(std::unique_ptr<BlimpMessage> message, |
| + const net::CompletionCallback& callback) override; |
| + |
| + private: |
| + // Sends engine an update of the client's geoposition. |
| + void OnLocationUpdate(const device::LocationProvider* location_provider, |
| + const device::Geoposition& position); |
| + |
| + // Communicates to the client a change of interest level from the engine. |
| + void SetInterestLevel(GeolocationSetInterestLevelMessage::Level level); |
| + |
| + // Creates a GeolocationPositionMessage that reflects the given |
| + // geoposition and sends it to the engine. |
| + void SendGeolocationPositionMessage(const device::Geoposition& position); |
| + |
| + // Creates a GeolocationErrorMessage that reflects the error defined |
| + // in the given geoposition and sends it. |
| + void SendGeolocationErrorMessage( |
| + 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?
|
| + const std::string& error_message); |
| + |
| + // Callback function when message finishes sending. |
| + void OnSendComplete(int result); |
| + |
| + // Used to obtain the client's location. |
| + std::unique_ptr<device::LocationProvider> location_provider_; |
| + |
| + // Used to send BlimpMessage::GEOLOCATION message to the engine. |
| + std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; |
| + |
| + // Run when message is finished sending. |
| + net::CompletionCallback completion_callback_; |
| + |
| + // 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.
|
| + bool can_send_message_ = true; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GeolocationFeature); |
| +}; |
| + |
| +} // namespace client |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_CLIENT_FEATURE_GEOLOCATION_FEATURE_H_ |