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

Side by Side Diff: components/cast_channel/cast_socket_service.h

Issue 2973983002: Revert of [Media Router] Add CastMediaSinkService (Closed)
Patch Set: Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_CAST_CHANNEL_CAST_CHANNEL_SERVICE_H_ 5 #ifndef COMPONENTS_CAST_CHANNEL_CAST_CHANNEL_SERVICE_H_
6 #define COMPONENTS_CAST_CHANNEL_CAST_CHANNEL_SERVICE_H_ 6 #define COMPONENTS_CAST_CHANNEL_CAST_CHANNEL_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 19 matching lines...) Expand all
30 // Adds |socket| to |sockets_| and returns raw pointer of |socket|. Takes 30 // Adds |socket| to |sockets_| and returns raw pointer of |socket|. Takes
31 // ownership of |socket|. 31 // ownership of |socket|.
32 CastSocket* AddSocket(std::unique_ptr<CastSocket> socket); 32 CastSocket* AddSocket(std::unique_ptr<CastSocket> socket);
33 33
34 // Removes the CastSocket corresponding to |channel_id| from the 34 // Removes the CastSocket corresponding to |channel_id| from the
35 // CastSocketRegistry. Returns nullptr if no such CastSocket exists. 35 // CastSocketRegistry. Returns nullptr if no such CastSocket exists.
36 std::unique_ptr<CastSocket> RemoveSocket(int channel_id); 36 std::unique_ptr<CastSocket> RemoveSocket(int channel_id);
37 37
38 // Returns the socket corresponding to |channel_id| if one exists, or nullptr 38 // Returns the socket corresponding to |channel_id| if one exists, or nullptr
39 // otherwise. 39 // otherwise.
40 virtual CastSocket* GetSocket(int channel_id) const; 40 CastSocket* GetSocket(int channel_id) const;
41 41
42 CastSocket* GetSocket(const net::IPEndPoint& ip_endpoint) const; 42 CastSocket* GetSocket(const net::IPEndPoint& ip_endpoint) const;
43 43
44 // Opens cast socket with |ip_endpoint| and invokes |open_cb| when opening 44 // Opens cast socket with |ip_endpoint| and invokes |open_cb| when opening
45 // operation finishes. If cast socket with |ip_endpoint| already exists, 45 // operation finishes. If cast socket with |ip_endpoint| already exists,
46 // invoke |open_cb| directly with existing socket's channel ID. 46 // invoke |open_cb| directly with existing socket's channel ID.
47 // Parameters: 47 // Parameters:
48 // |ip_endpoint|: IP address and port of the remote host. 48 // |ip_endpoint|: IP address and port of the remote host.
49 // |net_log|: Log of socket events. 49 // |net_log|: Log of socket events.
50 // |connect_timeout|: Connection timeout interval. 50 // |connect_timeout|: Connection timeout interval.
(...skipping 14 matching lines...) Expand all
65 CastSocket::Observer* observer); 65 CastSocket::Observer* observer);
66 66
67 // Opens cast socket with |ip_endpoint| and invokes |open_cb| when opening 67 // Opens cast socket with |ip_endpoint| and invokes |open_cb| when opening
68 // operation finishes. If cast socket with |ip_endpoint| already exists, 68 // operation finishes. If cast socket with |ip_endpoint| already exists,
69 // invoke |open_cb| directly with existing socket's channel ID. 69 // invoke |open_cb| directly with existing socket's channel ID.
70 // |ip_endpoint|: IP address and port of the remote host. 70 // |ip_endpoint|: IP address and port of the remote host.
71 // |net_log|: Log of socket events. 71 // |net_log|: Log of socket events.
72 // |open_cb|: OnOpenCallback invoked when cast socket is opened. 72 // |open_cb|: OnOpenCallback invoked when cast socket is opened.
73 // |observer|: Observer handles messages and errors on newly opened socket. 73 // |observer|: Observer handles messages and errors on newly opened socket.
74 // Does not take ownership of |observer|. 74 // Does not take ownership of |observer|.
75 virtual int OpenSocket(const net::IPEndPoint& ip_endpoint, 75 int OpenSocket(const net::IPEndPoint& ip_endpoint,
76 net::NetLog* net_log, 76 net::NetLog* net_log,
77 const CastSocket::OnOpenCallback& open_cb, 77 const CastSocket::OnOpenCallback& open_cb,
78 CastSocket::Observer* observer); 78 CastSocket::Observer* observer);
79 79
80 // Returns an observer corresponding to |id|. 80 // Returns an observer corresponding to |id|.
81 CastSocket::Observer* GetObserver(const std::string& id); 81 CastSocket::Observer* GetObserver(const std::string& id);
82 82
83 // Adds |observer| to |socket_observer_map_| keyed by |id|. Return raw pointer 83 // Adds |observer| to |socket_observer_map_| keyed by |id|. Return raw pointer
84 // of the newly added observer. 84 // of the newly added observer.
85 CastSocket::Observer* AddObserver( 85 CastSocket::Observer* AddObserver(
86 const std::string& id, 86 const std::string& id,
87 std::unique_ptr<CastSocket::Observer> observer); 87 std::unique_ptr<CastSocket::Observer> observer);
88 88
89 // Allow test to inject a mock cast socket. 89 // Allow test to inject a mock cast socket.
90 void SetSocketForTest(std::unique_ptr<CastSocket> socket_for_test); 90 void SetSocketForTest(std::unique_ptr<CastSocket> socket_for_test);
91 91
92 protected: 92 private:
93 ~CastSocketService() override; 93 ~CastSocketService() override;
94 94
95 private:
96 // RefcountedKeyedService implementation. 95 // RefcountedKeyedService implementation.
97 void ShutdownOnUIThread() override; 96 void ShutdownOnUIThread() override;
98 97
99 // Used to generate CastSocket id. 98 // Used to generate CastSocket id.
100 static int last_channel_id_; 99 static int last_channel_id_;
101 100
102 // The collection of CastSocket keyed by channel_id. 101 // The collection of CastSocket keyed by channel_id.
103 std::map<int, std::unique_ptr<CastSocket>> sockets_; 102 std::map<int, std::unique_ptr<CastSocket>> sockets_;
104 103
105 // Map of CastSocket::Observer keyed by observer id. For extension side 104 // Map of CastSocket::Observer keyed by observer id. For extension side
106 // observers, id is extension_id; For browser side observers, id is a hard 105 // observers, id is extension_id; For browser side observers, id is a hard
107 // coded string. 106 // coded string.
108 std::map<std::string, std::unique_ptr<CastSocket::Observer>> 107 std::map<std::string, std::unique_ptr<CastSocket::Observer>>
109 socket_observer_map_; 108 socket_observer_map_;
110 109
111 scoped_refptr<cast_channel::Logger> logger_; 110 scoped_refptr<cast_channel::Logger> logger_;
112 111
113 std::unique_ptr<CastSocket> socket_for_test_; 112 std::unique_ptr<CastSocket> socket_for_test_;
114 113
115 THREAD_CHECKER(thread_checker_); 114 THREAD_CHECKER(thread_checker_);
116 115
117 DISALLOW_COPY_AND_ASSIGN(CastSocketService); 116 DISALLOW_COPY_AND_ASSIGN(CastSocketService);
118 }; 117 };
119 118
120 } // namespace cast_channel 119 } // namespace cast_channel
121 120
122 #endif // COMPONENTS_CAST_CHANNEL_CAST_CHANNEL_SERVICE_H_ 121 #endif // COMPONENTS_CAST_CHANNEL_CAST_CHANNEL_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698