Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: components/cast_channel/cast_socket_service.h

Issue 2925053005: [cast_channel] Implement CastSocketService::OpenSocket() (Closed)
Patch Set: move |logger_| from cast_channel_api to cast_socket_service Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/cast_channel/cast_socket.cc ('k') | components/cast_channel/cast_socket_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..eea0aee1e190b259bbc1b84e06dfa8d8c9ffe439 100644
--- a/components/cast_channel/cast_socket_service.h
+++ b/components/cast_channel/cast_socket_service.h
@@ -24,9 +24,12 @@ 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);
+ // Returns a pointer to the Logger member variable.
+ scoped_refptr<cast_channel::Logger> GetLogger();
+
+ // 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 +39,44 @@ 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,
+ 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 +86,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 +107,10 @@ class CastSocketService : public RefcountedKeyedService {
std::map<std::string, std::unique_ptr<CastSocket::Observer>>
socket_observer_map_;
+ scoped_refptr<cast_channel::Logger> logger_;
+
+ std::unique_ptr<CastSocket> socket_for_test_;
+
THREAD_CHECKER(thread_checker_);
DISALLOW_COPY_AND_ASSIGN(CastSocketService);
« no previous file with comments | « components/cast_channel/cast_socket.cc ('k') | components/cast_channel/cast_socket_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698