| Index: components/cast_channel/cast_socket_service.h
|
| diff --git a/components/cast_channel/cast_socket_service.h b/components/cast_channel/cast_socket_service.h
|
| index 54cd715d7b40b98a0f83a7a65e48ef54dc4bbc40..14ca3f88d6136377e78d6ad6c24cd3ad40d81f4d 100644
|
| --- a/components/cast_channel/cast_socket_service.h
|
| +++ b/components/cast_channel/cast_socket_service.h
|
| @@ -24,9 +24,9 @@ class CastSocketService : public RefcountedKeyedService {
|
| public:
|
| CastSocketService();
|
|
|
| - // Adds |socket| to |sockets_| and returns the new channel_id. Takes ownership
|
| - // of |socket|.
|
| - int AddSocket(std::unique_ptr<CastSocket> socket);
|
| + // Adds |socket| to |sockets_| and returns raw pointer of |socket|. Takes
|
| + // ownership of |socket|.
|
| + CastSocket* AddSocket(std::unique_ptr<CastSocket> socket);
|
|
|
| // Removes the CastSocket corresponding to |channel_id| from the
|
| // CastSocketRegistry. Returns nullptr if no such CastSocket exists.
|
| @@ -36,6 +36,45 @@ class CastSocketService : public RefcountedKeyedService {
|
| // otherwise.
|
| CastSocket* GetSocket(int channel_id) const;
|
|
|
| + CastSocket* GetSocket(const net::IPEndPoint& ip_endpoint) const;
|
| +
|
| + // Opens cast socket with |ip_endpoint| and invokes |open_cb| when opening
|
| + // operation finishes. If cast socket with |ip_endpoint| already exists,
|
| + // invoke |open_cb| directly with existing socket's channel ID.
|
| + // Parameters:
|
| + // |ip_endpoint|: IP address and port of the remote host.
|
| + // |net_log|: Log of socket events.
|
| + // |connect_timeout|: Connection timeout interval.
|
| + // |liveness_timeout|: Liveness timeout for connect calls.
|
| + // |ping_interval|: Ping interval.
|
| + // |logger|: Log of cast channel events.
|
| + // |device_capabilities|: Device capabilities.
|
| + // |open_cb|: OnOpenCallback invoked when cast socket is opened.
|
| + // |observer|: Observer handles messages and errors on newly opened socket.
|
| + // Does not take ownership of |observer|.
|
| + int OpenSocket(const net::IPEndPoint& ip_endpoint,
|
| + net::NetLog* net_log,
|
| + const base::TimeDelta& connect_timeout,
|
| + const base::TimeDelta& liveness_timeout,
|
| + const base::TimeDelta& ping_interval,
|
| + const scoped_refptr<Logger>& logger,
|
| + uint64_t device_capabilities,
|
| + const CastSocket::OnOpenCallback& open_cb,
|
| + CastSocket::Observer* observer);
|
| +
|
| + // Opens cast socket with |ip_endpoint| and invokes |open_cb| when opening
|
| + // operation finishes. If cast socket with |ip_endpoint| already exists,
|
| + // invoke |open_cb| directly with existing socket's channel ID.
|
| + // |ip_endpoint|: IP address and port of the remote host.
|
| + // |net_log|: Log of socket events.
|
| + // |open_cb|: OnOpenCallback invoked when cast socket is opened.
|
| + // |observer|: Observer handles messages and errors on newly opened socket.
|
| + // Does not take ownership of |observer|.
|
| + int OpenSocket(const net::IPEndPoint& ip_endpoint,
|
| + net::NetLog* net_log,
|
| + const CastSocket::OnOpenCallback& open_cb,
|
| + CastSocket::Observer* observer);
|
| +
|
| // Returns an observer corresponding to |id|.
|
| CastSocket::Observer* GetObserver(const std::string& id);
|
|
|
| @@ -45,6 +84,9 @@ class CastSocketService : public RefcountedKeyedService {
|
| const std::string& id,
|
| std::unique_ptr<CastSocket::Observer> observer);
|
|
|
| + // Allow test to inject a mock cast socket.
|
| + void SetSocketForTest(std::unique_ptr<CastSocket> socket_for_test);
|
| +
|
| private:
|
| ~CastSocketService() override;
|
|
|
| @@ -63,6 +105,10 @@ class CastSocketService : public RefcountedKeyedService {
|
| std::map<std::string, std::unique_ptr<CastSocket::Observer>>
|
| socket_observer_map_;
|
|
|
| + scoped_refptr<Logger> logger_;
|
| +
|
| + std::unique_ptr<CastSocket> socket_for_test_;
|
| +
|
| THREAD_CHECKER(thread_checker_);
|
|
|
| DISALLOW_COPY_AND_ASSIGN(CastSocketService);
|
|
|