Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 VIDEO_OUT = 1 << 0, | 49 VIDEO_OUT = 1 << 0, |
| 50 VIDEO_IN = 1 << 1, | 50 VIDEO_IN = 1 << 1, |
| 51 AUDIO_OUT = 1 << 2, | 51 AUDIO_OUT = 1 << 2, |
| 52 AUDIO_IN = 1 << 3, | 52 AUDIO_IN = 1 << 3, |
| 53 DEV_MODE = 1 << 4 | 53 DEV_MODE = 1 << 4 |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // Public interface of the CastSocket class. | 56 // Public interface of the CastSocket class. |
| 57 class CastSocket { | 57 class CastSocket { |
| 58 public: | 58 public: |
| 59 using ChannelError = ::cast_channel::ChannelError; | |
| 60 using ChannelAuthType = ::cast_channel::ChannelAuthType; | |
| 61 using ReadyState = ::cast_channel::ReadyState; | |
| 62 | |
| 63 virtual ~CastSocket() {} | 59 virtual ~CastSocket() {} |
| 64 | 60 |
| 65 // Used by BrowserContextKeyedAPIFactory. | 61 // Used by BrowserContextKeyedAPIFactory. |
| 66 static const char* service_name() { return "CastSocketImplManager"; } | 62 static const char* service_name() { return "CastSocketImplManager"; } |
| 67 | 63 |
| 68 // Connects the channel to the peer. If successful, the channel will be in | 64 // Connects the channel to the peer. If successful, the channel will be in |
| 69 // READY_STATE_OPEN. DO NOT delete the CastSocket object in |callback|. | 65 // READY_STATE_OPEN. DO NOT delete the CastSocket object in |callback|. |
| 70 // Instead use Close(). | 66 // Instead use Close(). |
| 71 // |callback| will be invoked with any ChannelError that occurred, or | 67 // |callback| will be invoked with any ChannelError that occurred, or |
| 72 // CHANNEL_ERROR_NONE if successful. | 68 // CHANNEL_ERROR_NONE if successful. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 | 120 |
| 125 // This class implements a channel between Chrome and a Cast device using a TCP | 121 // This class implements a channel between Chrome and a Cast device using a TCP |
| 126 // socket with SSL. The channel may authenticate that the receiver is a genuine | 122 // socket with SSL. The channel may authenticate that the receiver is a genuine |
| 127 // Cast device. All CastSocketImpl objects must be used only on the IO thread. | 123 // Cast device. All CastSocketImpl objects must be used only on the IO thread. |
| 128 // | 124 // |
| 129 // NOTE: Not called "CastChannel" to reduce confusion with the generated API | 125 // NOTE: Not called "CastChannel" to reduce confusion with the generated API |
| 130 // code. | 126 // code. |
| 131 class CastSocketImpl : public CastSocket { | 127 class CastSocketImpl : public CastSocket { |
| 132 public: | 128 public: |
| 133 // Creates a new CastSocket that connects to |ip_endpoint| with | 129 // Creates a new CastSocket that connects to |ip_endpoint| with |
| 134 // |channel_auth|. |owner_extension_id| is the id of the extension that opened | 130 // |channel_auth|. |channel_auth| must not be CHANNEL_AUTH_NONE. |
|
mark a. foltz
2017/06/12 21:14:08
CHANNEL_AUTH_NONE has been removed from the IDL, s
zhaobin
2017/06/20 01:37:41
Created crbug.com/732669
| |
| 135 // the socket. |channel_auth| must not be CHANNEL_AUTH_NONE. | |
| 136 // Parameters: | 131 // Parameters: |
| 137 // |owner_extension_id|: ID of the extension calling the API. | |
| 138 // |ip_endpoint|: IP address of the remote host. | 132 // |ip_endpoint|: IP address of the remote host. |
| 139 // |channel_auth|: Authentication method used for connecting to a Cast | 133 // |channel_auth|: Authentication method used for connecting to a Cast |
| 140 // receiver. | 134 // receiver. |
| 141 // |net_log|: Log of socket events. | 135 // |net_log|: Log of socket events. |
| 142 // |connect_timeout|: Connection timeout interval. | 136 // |connect_timeout|: Connection timeout interval. |
| 143 // |logger|: Log of cast channel events. | 137 // |logger|: Log of cast channel events. |
| 144 CastSocketImpl(const std::string& owner_extension_id, | 138 CastSocketImpl(const net::IPEndPoint& ip_endpoint, |
| 145 const net::IPEndPoint& ip_endpoint, | |
| 146 ChannelAuthType channel_auth, | 139 ChannelAuthType channel_auth, |
| 147 net::NetLog* net_log, | 140 net::NetLog* net_log, |
| 148 const base::TimeDelta& connect_timeout, | 141 const base::TimeDelta& connect_timeout, |
| 149 bool keep_alive, | 142 bool keep_alive, |
| 150 const scoped_refptr<Logger>& logger, | 143 const scoped_refptr<Logger>& logger, |
| 151 uint64_t device_capabilities); | 144 uint64_t device_capabilities); |
| 152 | 145 |
| 153 // For test-only. | 146 // For test-only. |
| 154 // This constructor allows for setting a custom AuthContext. | 147 // This constructor allows for setting a custom AuthContext. |
| 155 CastSocketImpl(const std::string& owner_extension_id, | 148 CastSocketImpl(const net::IPEndPoint& ip_endpoint, |
| 156 const net::IPEndPoint& ip_endpoint, | |
| 157 ChannelAuthType channel_auth, | 149 ChannelAuthType channel_auth, |
| 158 net::NetLog* net_log, | 150 net::NetLog* net_log, |
| 159 const base::TimeDelta& connect_timeout, | 151 const base::TimeDelta& connect_timeout, |
| 160 bool keep_alive, | 152 bool keep_alive, |
| 161 const scoped_refptr<Logger>& logger, | 153 const scoped_refptr<Logger>& logger, |
| 162 uint64_t device_capabilities, | 154 uint64_t device_capabilities, |
| 163 const AuthContext& auth_context); | 155 const AuthContext& auth_context); |
| 164 | 156 |
| 165 // Ensures that the socket is closed. | 157 // Ensures that the socket is closed. |
| 166 ~CastSocketImpl() override; | 158 ~CastSocketImpl() override; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 | 377 |
| 386 // Raw pointer to the auth handshake delegate. Used to get detailed error | 378 // Raw pointer to the auth handshake delegate. Used to get detailed error |
| 387 // information. | 379 // information. |
| 388 AuthTransportDelegate* auth_delegate_; | 380 AuthTransportDelegate* auth_delegate_; |
| 389 | 381 |
| 390 DISALLOW_COPY_AND_ASSIGN(CastSocketImpl); | 382 DISALLOW_COPY_AND_ASSIGN(CastSocketImpl); |
| 391 }; | 383 }; |
| 392 } // namespace cast_channel | 384 } // namespace cast_channel |
| 393 | 385 |
| 394 #endif // COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_ | 386 #endif // COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_ |
| OLD | NEW |