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

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

Issue 2942743002: [cast_channel] Clean up CastSocketImpl ctor parameters (Closed)
Patch Set: fix compile error 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 unified diff | Download patch
« no previous file with comments | « components/cast_channel/cast_channel_enum.cc ('k') | components/cast_channel/cast_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SOCKET_H_ 5 #ifndef COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_
6 #define COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_ 6 #define COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 VIDEO_OUT = 1 << 0, 48 VIDEO_OUT = 1 << 0,
49 VIDEO_IN = 1 << 1, 49 VIDEO_IN = 1 << 1,
50 AUDIO_OUT = 1 << 2, 50 AUDIO_OUT = 1 << 2,
51 AUDIO_IN = 1 << 3, 51 AUDIO_IN = 1 << 3,
52 DEV_MODE = 1 << 4 52 DEV_MODE = 1 << 4
53 }; 53 };
54 54
55 // Public interface of the CastSocket class. 55 // Public interface of the CastSocket class.
56 class CastSocket { 56 class CastSocket {
57 public: 57 public:
58 using ChannelError = ::cast_channel::ChannelError;
59 using ChannelAuthType = ::cast_channel::ChannelAuthType;
60 using ReadyState = ::cast_channel::ReadyState;
61
62 virtual ~CastSocket() {} 58 virtual ~CastSocket() {}
63 59
64 // Used by BrowserContextKeyedAPIFactory. 60 // Used by BrowserContextKeyedAPIFactory.
65 static const char* service_name() { return "CastSocketImplManager"; } 61 static const char* service_name() { return "CastSocketImplManager"; }
66 62
67 // Connects the channel to the peer. If successful, the channel will be in 63 // Connects the channel to the peer. If successful, the channel will be in
68 // READY_STATE_OPEN. DO NOT delete the CastSocket object in |callback|. 64 // READY_STATE_OPEN. DO NOT delete the CastSocket object in |callback|.
69 // Instead use Close(). 65 // Instead use Close().
70 // |callback| will be invoked with any ChannelError that occurred, or 66 // |callback| will be invoked with any ChannelError that occurred, or
71 // CHANNEL_ERROR_NONE if successful. 67 // CHANNEL_ERROR_NONE if successful.
(...skipping 13 matching lines...) Expand all
85 81
86 // The IP endpoint for the destination of the channel. 82 // The IP endpoint for the destination of the channel.
87 virtual const net::IPEndPoint& ip_endpoint() const = 0; 83 virtual const net::IPEndPoint& ip_endpoint() const = 0;
88 84
89 // Channel id generated by the CastChannelService. 85 // Channel id generated by the CastChannelService.
90 virtual int id() const = 0; 86 virtual int id() const = 0;
91 87
92 // Sets the channel id generated by CastChannelService. 88 // Sets the channel id generated by CastChannelService.
93 virtual void set_id(int id) = 0; 89 virtual void set_id(int id) = 0;
94 90
95 // The authentication level requested for the channel.
96 virtual ChannelAuthType channel_auth() const = 0;
97
98 // The ready state of the channel. 91 // The ready state of the channel.
99 virtual ReadyState ready_state() const = 0; 92 virtual ReadyState ready_state() const = 0;
100 93
101 // Returns the last error that occurred on this channel, or 94 // Returns the last error that occurred on this channel, or
102 // CHANNEL_ERROR_NONE if no error has occurred. 95 // CHANNEL_ERROR_NONE if no error has occurred.
103 virtual ChannelError error_state() const = 0; 96 virtual ChannelError error_state() const = 0;
104 97
105 // True when keep-alive signaling is handled for this socket. 98 // True when keep-alive signaling is handled for this socket.
106 virtual bool keep_alive() const = 0; 99 virtual bool keep_alive() const = 0;
107 100
(...skipping 14 matching lines...) Expand all
122 }; 115 };
123 116
124 // This class implements a channel between Chrome and a Cast device using a TCP 117 // This class implements a channel between Chrome and a Cast device using a TCP
125 // socket with SSL. The channel may authenticate that the receiver is a genuine 118 // socket with SSL. The channel may authenticate that the receiver is a genuine
126 // Cast device. All CastSocketImpl objects must be used only on the IO thread. 119 // Cast device. All CastSocketImpl objects must be used only on the IO thread.
127 // 120 //
128 // NOTE: Not called "CastChannel" to reduce confusion with the generated API 121 // NOTE: Not called "CastChannel" to reduce confusion with the generated API
129 // code. 122 // code.
130 class CastSocketImpl : public CastSocket { 123 class CastSocketImpl : public CastSocket {
131 public: 124 public:
132 // Creates a new CastSocket that connects to |ip_endpoint| with 125 // Creates a new CastSocket that connects to |ip_endpoint|.
133 // |channel_auth|. |owner_extension_id| is the id of the extension that opened
134 // the socket. |channel_auth| must not be CHANNEL_AUTH_NONE.
135 // Parameters: 126 // Parameters:
136 // |owner_extension_id|: ID of the extension calling the API.
137 // |ip_endpoint|: IP address of the remote host. 127 // |ip_endpoint|: IP address of the remote host.
138 // |channel_auth|: Authentication method used for connecting to a Cast
139 // receiver.
140 // |net_log|: Log of socket events. 128 // |net_log|: Log of socket events.
141 // |connect_timeout|: Connection timeout interval. 129 // |connect_timeout|: Connection timeout interval.
142 // |logger|: Log of cast channel events. 130 // |logger|: Log of cast channel events.
143 CastSocketImpl(const std::string& owner_extension_id, 131 CastSocketImpl(const net::IPEndPoint& ip_endpoint,
144 const net::IPEndPoint& ip_endpoint,
145 ChannelAuthType channel_auth,
146 net::NetLog* net_log, 132 net::NetLog* net_log,
147 const base::TimeDelta& connect_timeout, 133 const base::TimeDelta& connect_timeout,
148 bool keep_alive, 134 bool keep_alive,
149 const scoped_refptr<Logger>& logger, 135 const scoped_refptr<Logger>& logger,
150 uint64_t device_capabilities); 136 uint64_t device_capabilities);
151 137
152 // For test-only. 138 // For test-only.
153 // This constructor allows for setting a custom AuthContext. 139 // This constructor allows for setting a custom AuthContext.
154 CastSocketImpl(const std::string& owner_extension_id, 140 CastSocketImpl(const net::IPEndPoint& ip_endpoint,
155 const net::IPEndPoint& ip_endpoint,
156 ChannelAuthType channel_auth,
157 net::NetLog* net_log, 141 net::NetLog* net_log,
158 const base::TimeDelta& connect_timeout, 142 const base::TimeDelta& connect_timeout,
159 bool keep_alive, 143 bool keep_alive,
160 const scoped_refptr<Logger>& logger, 144 const scoped_refptr<Logger>& logger,
161 uint64_t device_capabilities, 145 uint64_t device_capabilities,
162 const AuthContext& auth_context); 146 const AuthContext& auth_context);
163 147
164 // Ensures that the socket is closed. 148 // Ensures that the socket is closed.
165 ~CastSocketImpl() override; 149 ~CastSocketImpl() override;
166 150
167 // CastSocket interface. 151 // CastSocket interface.
168 void Connect(std::unique_ptr<CastTransport::Delegate> delegate, 152 void Connect(std::unique_ptr<CastTransport::Delegate> delegate,
169 base::Callback<void(ChannelError)> callback) override; 153 base::Callback<void(ChannelError)> callback) override;
170 CastTransport* transport() const override; 154 CastTransport* transport() const override;
171 void Close(const net::CompletionCallback& callback) override; 155 void Close(const net::CompletionCallback& callback) override;
172 const net::IPEndPoint& ip_endpoint() const override; 156 const net::IPEndPoint& ip_endpoint() const override;
173 int id() const override; 157 int id() const override;
174 void set_id(int channel_id) override; 158 void set_id(int channel_id) override;
175 ChannelAuthType channel_auth() const override;
176 ReadyState ready_state() const override; 159 ReadyState ready_state() const override;
177 ChannelError error_state() const override; 160 ChannelError error_state() const override;
178 bool keep_alive() const override; 161 bool keep_alive() const override;
179 bool audio_only() const override; 162 bool audio_only() const override;
180 163
181 protected: 164 protected:
182 // CastTransport::Delegate methods for receiving handshake messages. 165 // CastTransport::Delegate methods for receiving handshake messages.
183 class AuthTransportDelegate : public CastTransport::Delegate { 166 class AuthTransportDelegate : public CastTransport::Delegate {
184 public: 167 public:
185 explicit AuthTransportDelegate(CastSocketImpl* socket); 168 explicit AuthTransportDelegate(CastSocketImpl* socket);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 271
289 void SetConnectState(ConnectionState connect_state); 272 void SetConnectState(ConnectionState connect_state);
290 void SetReadyState(ReadyState ready_state); 273 void SetReadyState(ReadyState ready_state);
291 274
292 THREAD_CHECKER(thread_checker_); 275 THREAD_CHECKER(thread_checker_);
293 276
294 // The id of the channel. 277 // The id of the channel.
295 int channel_id_; 278 int channel_id_;
296 // The IP endpoint that the the channel is connected to. 279 // The IP endpoint that the the channel is connected to.
297 net::IPEndPoint ip_endpoint_; 280 net::IPEndPoint ip_endpoint_;
298 // Receiver authentication requested for the channel.
299 ChannelAuthType channel_auth_;
300 // The NetLog for this service. 281 // The NetLog for this service.
301 net::NetLog* net_log_; 282 net::NetLog* net_log_;
302 // The NetLog source for this service. 283 // The NetLog source for this service.
303 net::NetLogSource net_log_source_; 284 net::NetLogSource net_log_source_;
304 // True when keep-alive signaling should be handled for this socket. 285 // True when keep-alive signaling should be handled for this socket.
305 bool keep_alive_; 286 bool keep_alive_;
306 287
307 // Shared logging object, used to log CastSocket events for diagnostics. 288 // Shared logging object, used to log CastSocket events for diagnostics.
308 scoped_refptr<Logger> logger_; 289 scoped_refptr<Logger> logger_;
309 290
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 365
385 // Raw pointer to the auth handshake delegate. Used to get detailed error 366 // Raw pointer to the auth handshake delegate. Used to get detailed error
386 // information. 367 // information.
387 AuthTransportDelegate* auth_delegate_; 368 AuthTransportDelegate* auth_delegate_;
388 369
389 DISALLOW_COPY_AND_ASSIGN(CastSocketImpl); 370 DISALLOW_COPY_AND_ASSIGN(CastSocketImpl);
390 }; 371 };
391 } // namespace cast_channel 372 } // namespace cast_channel
392 373
393 #endif // COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_ 374 #endif // COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_
OLDNEW
« no previous file with comments | « components/cast_channel/cast_channel_enum.cc ('k') | components/cast_channel/cast_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698