Chromium Code Reviews| Index: content/browser/renderer_host/p2p/socket_host_tcp.cc |
| =================================================================== |
| --- content/browser/renderer_host/p2p/socket_host_tcp.cc (revision 205587) |
| +++ content/browser/renderer_host/p2p/socket_host_tcp.cc (working copy) |
| @@ -7,6 +7,7 @@ |
| #include "base/sys_byteorder.h" |
| #include "content/common/p2p_messages.h" |
| #include "ipc/ipc_sender.h" |
| +#include "jingle/glue/fake_ssl_client_socket.h" |
| #include "net/base/io_buffer.h" |
| #include "net/base/net_errors.h" |
| #include "net/base/net_util.h" |
| @@ -20,15 +21,22 @@ |
| const int kPacketLengthOffset = 2; |
| const int kTurnChannelDataHeaderSize = 4; |
| +bool IsSslClientSocket(content::P2PSocketType type) { |
| + return (type == content::P2P_SOCKET_SSLTCP_CLIENT || |
| + type == content::P2P_SOCKET_STUN_SSLTCP_CLIENT); |
| +} |
| + |
| } // namespace |
| namespace content { |
| P2PSocketHostTcpBase::P2PSocketHostTcpBase(IPC::Sender* message_sender, |
| - int id) |
| + int id, |
| + P2PSocketType type) |
| : P2PSocketHost(message_sender, id), |
| write_pending_(false), |
| - connected_(false) { |
| + connected_(false), |
| + type_(type) { |
| } |
| P2PSocketHostTcpBase::~P2PSocketHostTcpBase() { |
| @@ -44,6 +52,7 @@ |
| DCHECK_EQ(state_, STATE_UNINITIALIZED); |
| remote_address_ = remote_address; |
| + // TODO(ronghuawu): Add FakeSSLServerSocket. |
| socket_.reset(socket); |
| state_ = STATE_OPEN; |
| DoRead(); |
| @@ -63,7 +72,11 @@ |
| OnError(); |
| return false; |
| } |
| - socket_.reset(tcp_socket.release()); |
| + if (IsSslClientSocket(type_)) { |
| + socket_.reset(new jingle_glue::FakeSSLClientSocket(tcp_socket.release())); |
| + } else { |
| + socket_.reset(tcp_socket.release()); |
|
Sergey Ulanov
2013/06/19 00:03:10
nit: change this to socket_ = tcp_socket.PassAs<ne
Ronghua Wu (Left Chromium)
2013/06/19 00:17:30
Done.
|
| + } |
| int result = socket_->Connect( |
| base::Bind(&P2PSocketHostTcp::OnConnected, base::Unretained(this))); |
| @@ -272,8 +285,10 @@ |
| } |
| } |
| -P2PSocketHostTcp::P2PSocketHostTcp(IPC::Sender* message_sender, int id) |
| - : P2PSocketHostTcpBase(message_sender, id) { |
| +P2PSocketHostTcp::P2PSocketHostTcp(IPC::Sender* message_sender, |
| + int id, |
| + P2PSocketType type) |
| + : P2PSocketHostTcpBase(message_sender, id, type) { |
| } |
|
Sergey Ulanov
2013/06/19 00:03:10
DCHECK that type is supported by this class. Same
Ronghua Wu (Left Chromium)
2013/06/19 00:17:30
Done.
|
| P2PSocketHostTcp::~P2PSocketHostTcp() { |
| @@ -307,8 +322,9 @@ |
| // P2PSocketHostStunTcp |
| P2PSocketHostStunTcp::P2PSocketHostStunTcp(IPC::Sender* message_sender, |
| - int id) |
| - : P2PSocketHostTcpBase(message_sender, id) { |
| + int id, |
| + P2PSocketType type) |
| + : P2PSocketHostTcpBase(message_sender, id, type) { |
| } |
| P2PSocketHostStunTcp::~P2PSocketHostStunTcp() { |