aboutsummaryrefslogtreecommitdiff
path: root/cast/streaming/environment.h
diff options
context:
space:
mode:
authorYuri Wiitala <miu@chromium.org>2019-12-20 20:26:40 -0800
committerCommit Bot <commit-bot@chromium.org>2019-12-21 08:46:52 +0000
commit80ed3d779e3e38de94656bf59ff4b62534c797fe (patch)
tree7e5272420823e8f7a6bca54df9f259179d3fe126 /cast/streaming/environment.h
parent14e7402b939822d20a2cf72e84cb72136301c4aa (diff)
downloadopenscreen-80ed3d779e3e38de94656bf59ff4b62534c797fe.tar.gz
Replace namespace cast::something with openscreen::cast.
...and fixed a few C++ style issues around use of rvals in files touched. Bug: openscreen:90 Change-Id: Ib14fb1c47dfafec1fefe0cad31bce764aae0272e Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1959204 Commit-Queue: Yuri Wiitala <miu@chromium.org> Reviewed-by: Jordan Bayles <jophba@chromium.org>
Diffstat (limited to 'cast/streaming/environment.h')
-rw-r--r--cast/streaming/environment.h56
1 files changed, 23 insertions, 33 deletions
diff --git a/cast/streaming/environment.h b/cast/streaming/environment.h
index 5fb613f5..e96359ad 100644
--- a/cast/streaming/environment.h
+++ b/cast/streaming/environment.h
@@ -16,20 +16,16 @@
#include "platform/base/ip_address.h"
namespace openscreen {
-class TaskRunner;
-} // namespace openscreen
-
namespace cast {
-namespace streaming {
// Provides the common environment for operating system resources shared by
// multiple components.
-class Environment : public openscreen::UdpSocket::Client {
+class Environment : public UdpSocket::Client {
public:
class PacketConsumer {
public:
- virtual void OnReceivedPacket(const openscreen::IPEndpoint& source,
- openscreen::Clock::time_point arrival_time,
+ virtual void OnReceivedPacket(const IPEndpoint& source,
+ Clock::time_point arrival_time,
std::vector<uint8_t> packet) = 0;
protected:
@@ -39,33 +35,30 @@ class Environment : public openscreen::UdpSocket::Client {
// Construct with the given clock source and TaskRunner. Creates and
// internally-owns a UdpSocket, and immediately binds it to the given
// |local_endpoint|.
- Environment(openscreen::ClockNowFunctionPtr now_function,
- openscreen::TaskRunner* task_runner,
- const openscreen::IPEndpoint& local_endpoint);
+ Environment(ClockNowFunctionPtr now_function,
+ TaskRunner* task_runner,
+ const IPEndpoint& local_endpoint);
~Environment() override;
- openscreen::ClockNowFunctionPtr now_function() const { return now_function_; }
- openscreen::TaskRunner* task_runner() const { return task_runner_; }
+ ClockNowFunctionPtr now_function() const { return now_function_; }
+ TaskRunner* task_runner() const { return task_runner_; }
// Returns the local endpoint the socket is bound to, or the zero IPEndpoint
// if socket creation/binding failed.
- openscreen::IPEndpoint GetBoundLocalEndpoint() const;
+ IPEndpoint GetBoundLocalEndpoint() const;
// Set a handler function to run whenever non-recoverable socket errors occur.
// If never set, the default is to emit log messages at error priority.
- void set_socket_error_handler(
- std::function<void(openscreen::Error)> handler) {
+ void set_socket_error_handler(std::function<void(Error)> handler) {
socket_error_handler_ = handler;
}
// Get/Set the remote endpoint. This is separate from the constructor because
// the remote endpoint is, in some cases, discovered only after receiving a
// packet.
- const openscreen::IPEndpoint& remote_endpoint() const {
- return remote_endpoint_;
- }
- void set_remote_endpoint(const openscreen::IPEndpoint& endpoint) {
+ const IPEndpoint& remote_endpoint() const { return remote_endpoint_; }
+ void set_remote_endpoint(const IPEndpoint& endpoint) {
remote_endpoint_ = endpoint;
}
@@ -93,32 +86,29 @@ class Environment : public openscreen::UdpSocket::Client {
// Common constructor that just stores the injected dependencies and does not
// create a socket. Subclasses use this to provide an alternative packet
// receive/send mechanism (e.g., for testing).
- Environment(openscreen::ClockNowFunctionPtr now_function,
- openscreen::TaskRunner* task_runner);
+ Environment(ClockNowFunctionPtr now_function, TaskRunner* task_runner);
private:
- // openscreen::UdpSocket::Client implementation.
- void OnError(openscreen::UdpSocket* socket, openscreen::Error error) final;
- void OnSendError(openscreen::UdpSocket* socket,
- openscreen::Error error) final;
- void OnRead(openscreen::UdpSocket* socket,
- openscreen::ErrorOr<openscreen::UdpPacket> packet_or_error) final;
+ // UdpSocket::Client implementation.
+ void OnError(UdpSocket* socket, Error error) final;
+ void OnSendError(UdpSocket* socket, Error error) final;
+ void OnRead(UdpSocket* socket, ErrorOr<UdpPacket> packet_or_error) final;
- const openscreen::ClockNowFunctionPtr now_function_;
- openscreen::TaskRunner* const task_runner_;
+ const ClockNowFunctionPtr now_function_;
+ TaskRunner* const task_runner_;
// The UDP socket bound to the local endpoint that was passed into the
// constructor, or null if socket creation failed.
- const std::unique_ptr<openscreen::UdpSocket> socket_;
+ const std::unique_ptr<UdpSocket> socket_;
// These are externally set/cleared. Behaviors are described in getter/setter
// method comments above.
- std::function<void(openscreen::Error)> socket_error_handler_;
- openscreen::IPEndpoint remote_endpoint_{};
+ std::function<void(Error)> socket_error_handler_;
+ IPEndpoint remote_endpoint_{};
PacketConsumer* packet_consumer_ = nullptr;
};
-} // namespace streaming
} // namespace cast
+} // namespace openscreen
#endif // CAST_STREAMING_ENVIRONMENT_H_