diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-20 00:25:44 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-20 00:25:44 +0000 |
commit | 73a19c12e411363d77441703040f39a681189efc (patch) | |
tree | 7e506f0acd7d5827a466a48292a571dea2fbdcb8 /content | |
parent | 89d6ed0dd24285258c7371b3c24f5a5859b99ae3 (diff) | |
download | chromium_src-73a19c12e411363d77441703040f39a681189efc.zip chromium_src-73a19c12e411363d77441703040f39a681189efc.tar.gz chromium_src-73a19c12e411363d77441703040f39a681189efc.tar.bz2 |
Enable TCP sockets for P2P IPC.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/6879042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/p2p/socket_dispatcher_host.cc | 6 | ||||
-rw-r--r-- | content/browser/renderer_host/p2p/socket_dispatcher_host.h | 26 | ||||
-rw-r--r-- | content/browser/renderer_host/p2p/socket_host_tcp.cc | 25 | ||||
-rw-r--r-- | content/browser/renderer_host/p2p/socket_host_tcp.h | 3 | ||||
-rw-r--r-- | content/browser/renderer_host/p2p/socket_host_tcp_server.cc | 10 | ||||
-rw-r--r-- | content/common/p2p_messages.h | 3 | ||||
-rw-r--r-- | content/renderer/p2p/ipc_socket_factory.cc | 104 | ||||
-rw-r--r-- | content/renderer/p2p/socket_client.cc | 47 | ||||
-rw-r--r-- | content/renderer/p2p/socket_client.h | 13 | ||||
-rw-r--r-- | content/renderer/p2p/socket_dispatcher.cc | 9 | ||||
-rw-r--r-- | content/renderer/p2p/socket_dispatcher.h | 1 |
11 files changed, 182 insertions, 65 deletions
diff --git a/content/browser/renderer_host/p2p/socket_dispatcher_host.cc b/content/browser/renderer_host/p2p/socket_dispatcher_host.cc index 7d39880..aa7bcf7 100644 --- a/content/browser/renderer_host/p2p/socket_dispatcher_host.cc +++ b/content/browser/renderer_host/p2p/socket_dispatcher_host.cc @@ -71,6 +71,7 @@ bool P2PSocketDispatcherHost::OnMessageReceived(const IPC::Message& message, void P2PSocketDispatcherHost::OnCreateSocket( const IPC::Message& msg, P2PSocketType type, int socket_id, + const net::IPEndPoint& local_address, const net::IPEndPoint& remote_address) { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, NewRunnableMethod( @@ -111,11 +112,6 @@ void P2PSocketDispatcherHost::FinishCreateSocket( return; } - if (type != P2P_SOCKET_UDP) { - Send(new P2PMsg_OnError(routing_id, socket_id)); - return; - } - scoped_ptr<P2PSocketHost> socket( P2PSocketHost::Create(this, routing_id, socket_id, type)); diff --git a/content/browser/renderer_host/p2p/socket_dispatcher_host.h b/content/browser/renderer_host/p2p/socket_dispatcher_host.h index 316f241..aae218e 100644 --- a/content/browser/renderer_host/p2p/socket_dispatcher_host.h +++ b/content/browser/renderer_host/p2p/socket_dispatcher_host.h @@ -25,8 +25,11 @@ class P2PSocketDispatcherHost : public BrowserMessageFilter { private: // Handlers for the messages coming from the renderer. - void OnCreateSocket(const IPC::Message& msg, P2PSocketType type, - int socket_id, const net::IPEndPoint& remote_address); + void OnCreateSocket(const IPC::Message& msg, + P2PSocketType type, + int socket_id, + const net::IPEndPoint& local_address, + const net::IPEndPoint& remote_address); void OnAcceptIncomingTcpConnection(int listen_socket_id, net::IPEndPoint remote_address, int connected_socket_id); @@ -37,14 +40,17 @@ class P2PSocketDispatcherHost : public BrowserMessageFilter { // Helpers for OnCreateSocket(). // - // TODO(sergeyu): Remove these methods. |local_address| should be a - // parameter in the CreateSocket() message. - void GetLocalAddressAndCreateSocket( - int routing_id, P2PSocketType type, int socket_id, - const net::IPEndPoint& remote_address); - void FinishCreateSocket( - int routing_id, const net::IPEndPoint& local_address, P2PSocketType type, - int socket_id, const net::IPEndPoint& remote_address); + // TODO(sergeyu): Remove these methods. Use |local_address| passed + // in OnCreateSocket(). + void GetLocalAddressAndCreateSocket(int routing_id, + P2PSocketType type, + int socket_id, + const net::IPEndPoint& remote_address); + void FinishCreateSocket(int routing_id, + const net::IPEndPoint& local_address, + P2PSocketType type, + int socket_id, + const net::IPEndPoint& remote_address); IDMap<P2PSocketHost, IDMapOwnPointer> sockets_; diff --git a/content/browser/renderer_host/p2p/socket_host_tcp.cc b/content/browser/renderer_host/p2p/socket_host_tcp.cc index c5bfb65..2e169d3 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp.cc +++ b/content/browser/renderer_host/p2p/socket_host_tcp.cc @@ -4,18 +4,11 @@ #include "content/browser/renderer_host/p2p/socket_host_tcp.h" -#include "build/build_config.h" - -#if defined(OS_WIN) -#include <winsock2.h> // for htonl -#else -#include <arpa/inet.h> -#endif - #include "content/common/p2p_messages.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/base/net_util.h" +#include "net/base/sys_byteorder.h" #include "net/socket/tcp_client_socket.h" namespace { @@ -43,21 +36,27 @@ P2PSocketHostTcp::~P2PSocketHostTcp() { } } -bool P2PSocketHostTcp::InitAccepted(const net::IPEndPoint& local_address, - const net::IPEndPoint& remote_address, +bool P2PSocketHostTcp::InitAccepted(const net::IPEndPoint& remote_address, net::ClientSocket* socket) { + DCHECK(socket); DCHECK_EQ(state_, STATE_UNINITIALIZED); - state_ = STATE_CONNECTING; - OnConnected(net::OK); + + remote_address_ = remote_address; + socket_.reset(socket); + state_ = STATE_OPEN; + DoRead(); return state_ != STATE_ERROR; } bool P2PSocketHostTcp::Init(const net::IPEndPoint& local_address, const net::IPEndPoint& remote_address) { DCHECK_EQ(state_, STATE_UNINITIALIZED); + + remote_address_ = remote_address; state_ = STATE_CONNECTING; socket_.reset(new net::TCPClientSocket( - net::AddressList(), NULL, net::NetLog::Source())); + net::AddressList(remote_address.address(), remote_address.port(), false), + NULL, net::NetLog::Source())); int result = socket_->Connect(&connect_callback_); if (result != net::ERR_IO_PENDING) { OnConnected(result); diff --git a/content/browser/renderer_host/p2p/socket_host_tcp.h b/content/browser/renderer_host/p2p/socket_host_tcp.h index b721c2b..917e622 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp.h +++ b/content/browser/renderer_host/p2p/socket_host_tcp.h @@ -26,8 +26,7 @@ class P2PSocketHostTcp : public P2PSocketHost { int routing_id, int id); virtual ~P2PSocketHostTcp(); - bool InitAccepted(const net::IPEndPoint& local_address, - const net::IPEndPoint& remote_address, + bool InitAccepted(const net::IPEndPoint& remote_address, net::ClientSocket* socket); // P2PSocketHost overrides. diff --git a/content/browser/renderer_host/p2p/socket_host_tcp_server.cc b/content/browser/renderer_host/p2p/socket_host_tcp_server.cc index 7e7f65f..ae5ed2b 100644 --- a/content/browser/renderer_host/p2p/socket_host_tcp_server.cc +++ b/content/browser/renderer_host/p2p/socket_host_tcp_server.cc @@ -128,8 +128,10 @@ P2PSocketHost* P2PSocketHostTcpServer::AcceptIncomingTcpConnection( net::ClientSocket* socket = it->second; accepted_sockets_.erase(it); - P2PSocketHostTcp* result = - new P2PSocketHostTcp(message_sender_, routing_id_, id); - result->InitAccepted(local_address_, remote_address, socket); - return result; + scoped_ptr<P2PSocketHostTcp> result( + new P2PSocketHostTcp(message_sender_, routing_id_, id)); + if (!result->InitAccepted(remote_address, socket)) + return NULL; + + return result.release(); } diff --git a/content/common/p2p_messages.h b/content/common/p2p_messages.h index b8ba4d0..1d10e01 100644 --- a/content/common/p2p_messages.h +++ b/content/common/p2p_messages.h @@ -33,9 +33,10 @@ IPC_MESSAGE_ROUTED3(P2PMsg_OnDataReceived, // P2P Socket messages sent from the renderer to the browser. -IPC_MESSAGE_ROUTED3(P2PHostMsg_CreateSocket, +IPC_MESSAGE_ROUTED4(P2PHostMsg_CreateSocket, P2PSocketType /* type */, int /* socket_id */, + net::IPEndPoint /* local_address */, net::IPEndPoint /* remote_address */) IPC_MESSAGE_ROUTED3(P2PHostMsg_AcceptIncomingTcpConnection, diff --git a/content/renderer/p2p/ipc_socket_factory.cc b/content/renderer/p2p/ipc_socket_factory.cc index 565e692..62507f4 100644 --- a/content/renderer/p2p/ipc_socket_factory.cc +++ b/content/renderer/p2p/ipc_socket_factory.cc @@ -4,6 +4,7 @@ #include "content/renderer/p2p/ipc_socket_factory.h" +#include "base/compiler_specific.h" #include "base/message_loop.h" #include "base/message_loop_proxy.h" #include "content/renderer/p2p/socket_client.h" @@ -22,8 +23,10 @@ class IpcPacketSocket : public talk_base::AsyncPacketSocket, IpcPacketSocket(); virtual ~IpcPacketSocket(); + // Always takes ownership of client even if initialization fails. bool Init(P2PSocketType type, P2PSocketClient* client, - const talk_base::SocketAddress& address); + const talk_base::SocketAddress& local_address, + const talk_base::SocketAddress& remote_address); // talk_base::AsyncPacketSocket interface. virtual talk_base::SocketAddress GetLocalAddress(bool* allocated) const; @@ -38,11 +41,13 @@ class IpcPacketSocket : public talk_base::AsyncPacketSocket, virtual int GetError() const; virtual void SetError(int error); - // P2PSocketClient::Delegate - virtual void OnOpen(const net::IPEndPoint& address); + // P2PSocketClient::Delegate implementation. + virtual void OnOpen(const net::IPEndPoint& address) OVERRIDE; + virtual void OnIncomingTcpConnection(const net::IPEndPoint& address, + P2PSocketClient* client) OVERRIDE; virtual void OnError(); virtual void OnDataReceived(const net::IPEndPoint& address, - const std::vector<char>& data); + const std::vector<char>& data) OVERRIDE; private: enum State { @@ -53,6 +58,10 @@ class IpcPacketSocket : public talk_base::AsyncPacketSocket, STATE_ERROR, }; + void InitAcceptedTcp(P2PSocketClient* client, + const talk_base::SocketAddress& local_address, + const talk_base::SocketAddress& remote_address); + // Message loop on which this socket was created and being used. MessageLoop* message_loop_; @@ -91,31 +100,55 @@ IpcPacketSocket::~IpcPacketSocket() { } bool IpcPacketSocket::Init(P2PSocketType type, P2PSocketClient* client, - const talk_base::SocketAddress& address) { + const talk_base::SocketAddress& local_address, + const talk_base::SocketAddress& remote_address) { DCHECK_EQ(MessageLoop::current(), message_loop_); DCHECK_EQ(state_, STATE_UNINITIALIZED); client_ = client; - remote_address_ = address; + local_address_ = local_address; + remote_address_ = remote_address; state_ = STATE_OPENING; - net::IPEndPoint address_chrome; - if (!jingle_glue::SocketAddressToIPEndPoint(address, &address_chrome)) { + net::IPEndPoint local_endpoint; + if (!jingle_glue::SocketAddressToIPEndPoint(local_address, &local_endpoint)) { + return false; + } + + net::IPEndPoint remote_endpoint; + if (!jingle_glue::SocketAddressToIPEndPoint( + remote_address, &remote_endpoint)) { return false; } - client_->Init(type, address_chrome, this, + client_->Init(type, local_endpoint, remote_endpoint, this, base::MessageLoopProxy::CreateForCurrentThread()); return true; } +void IpcPacketSocket::InitAcceptedTcp( + P2PSocketClient* client, + const talk_base::SocketAddress& local_address, + const talk_base::SocketAddress& remote_address) { + DCHECK_EQ(MessageLoop::current(), message_loop_); + DCHECK_EQ(state_, STATE_UNINITIALIZED); + + client_ = client; + local_address_ = local_address; + remote_address_ = remote_address; + state_ = STATE_OPEN; + client_->set_delegate(this); +} + // talk_base::AsyncPacketSocket interface. talk_base::SocketAddress IpcPacketSocket::GetLocalAddress( bool* allocated) const { DCHECK_EQ(MessageLoop::current(), message_loop_); - *allocated = address_initialized_; + if (allocated) { + *allocated = address_initialized_; + } return local_address_; } @@ -225,12 +258,30 @@ void IpcPacketSocket::OnOpen(const net::IPEndPoint& address) { if (!jingle_glue::IPEndPointToSocketAddress(address, &local_address_)) { // Always expect correct IPv4 address to be allocated. NOTREACHED(); + OnError(); + return; } SignalAddressReady(this, local_address_); address_initialized_ = true; state_ = STATE_OPEN; } +void IpcPacketSocket::OnIncomingTcpConnection( + const net::IPEndPoint& address, + P2PSocketClient* client) { + DCHECK_EQ(MessageLoop::current(), message_loop_); + + scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); + + talk_base::SocketAddress remote_address; + if (!jingle_glue::IPEndPointToSocketAddress(address, &remote_address)) { + // Always expect correct IPv4 address to be allocated. + NOTREACHED(); + } + socket->InitAcceptedTcp(client, local_address_, remote_address); + SignalNewConnection(this, socket.release()); +} + void IpcPacketSocket::OnError() { DCHECK_EQ(MessageLoop::current(), message_loop_); state_ = STATE_ERROR; @@ -270,20 +321,27 @@ talk_base::AsyncPacketSocket* IpcPacketSocketFactory::CreateUdpSocket( // TODO(sergeyu): Respect local_address and port limits here (need // to pass them over IPC channel to the browser). if (!socket->Init(P2P_SOCKET_UDP, socket_client, - talk_base::SocketAddress())) { + local_address, talk_base::SocketAddress())) { return NULL; } - - // Socket increments reference count if Init() was successful. return socket.release(); } talk_base::AsyncPacketSocket* IpcPacketSocketFactory::CreateServerTcpSocket( const talk_base::SocketAddress& local_address, int min_port, int max_port, bool listen, bool ssl) { - // TODO(sergeyu): Implement this. - NOTIMPLEMENTED(); - return NULL; + // TODO(sergeyu): Implement SSL support. + if (ssl) + return NULL; + + talk_base::SocketAddress crome_address; + P2PSocketClient* socket_client = new P2PSocketClient(socket_dispatcher_); + scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); + if (!socket->Init(P2P_SOCKET_TCP_SERVER, socket_client, local_address, + talk_base::SocketAddress())) { + return NULL; + } + return socket.release(); } talk_base::AsyncPacketSocket* IpcPacketSocketFactory::CreateClientTcpSocket( @@ -291,7 +349,15 @@ talk_base::AsyncPacketSocket* IpcPacketSocketFactory::CreateClientTcpSocket( const talk_base::SocketAddress& remote_address, const talk_base::ProxyInfo& proxy_info, const std::string& user_agent, bool ssl) { - // TODO(sergeyu): Implement this; - NOTIMPLEMENTED(); - return NULL; + // TODO(sergeyu): Implement SSL support. + if (ssl) + return NULL; + + talk_base::SocketAddress crome_address; + P2PSocketClient* socket_client = new P2PSocketClient(socket_dispatcher_); + scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); + if (!socket->Init(P2P_SOCKET_TCP_CLIENT, socket_client, local_address, + remote_address)) + return NULL; + return socket.release(); } diff --git a/content/renderer/p2p/socket_client.cc b/content/renderer/p2p/socket_client.cc index c038c19..b98233b 100644 --- a/content/renderer/p2p/socket_client.cc +++ b/content/renderer/p2p/socket_client.cc @@ -17,18 +17,18 @@ P2PSocketClient::P2PSocketClient(P2PSocketDispatcher* dispatcher) } P2PSocketClient::~P2PSocketClient() { - DCHECK(state_ == STATE_CLOSED || state_ == STATE_UNINITIALIZED || - state_ == STATE_ERROR); + DCHECK(state_ == STATE_CLOSED || state_ == STATE_UNINITIALIZED); } void P2PSocketClient::Init( - P2PSocketType type, const net::IPEndPoint& address, - P2PSocketClient::Delegate* delegate, + P2PSocketType type, const net::IPEndPoint& local_address, + const net::IPEndPoint& remote_address, P2PSocketClient::Delegate* delegate, scoped_refptr<base::MessageLoopProxy> delegate_loop) { if (!ipc_message_loop_->BelongsToCurrentThread()) { ipc_message_loop_->PostTask( - FROM_HERE, NewRunnableMethod(this, &P2PSocketClient::Init, - type, address, delegate, delegate_loop)); + FROM_HERE, NewRunnableMethod( + this, &P2PSocketClient::Init, type, local_address, remote_address, + delegate, delegate_loop)); return; } @@ -37,8 +37,8 @@ void P2PSocketClient::Init( delegate_ = delegate; delegate_message_loop_ = delegate_loop; socket_id_ = dispatcher_->RegisterClient(this); - dispatcher_->SendP2PMessage( - new P2PHostMsg_CreateSocket(0, type, socket_id_, address)); + dispatcher_->SendP2PMessage(new P2PHostMsg_CreateSocket( + 0, type, socket_id_, local_address, remote_address)); } void P2PSocketClient::Send(const net::IPEndPoint& address, @@ -67,7 +67,8 @@ void P2PSocketClient::Close() { void P2PSocketClient::DoClose() { if (dispatcher_) { - if (state_ == STATE_OPEN || state_ == STATE_OPENING) { + if (state_ == STATE_OPEN || state_ == STATE_OPENING || + state_ == STATE_ERROR) { dispatcher_->SendP2PMessage(new P2PHostMsg_DestroySocket(0, socket_id_)); } dispatcher_->UnregisterClient(socket_id_); @@ -76,6 +77,11 @@ void P2PSocketClient::DoClose() { state_ = STATE_CLOSED; } +void P2PSocketClient::set_delegate(Delegate* delegate) { + DCHECK(delegate_message_loop_->BelongsToCurrentThread()); + delegate_ = delegate; +} + void P2PSocketClient::OnSocketCreated(const net::IPEndPoint& address) { DCHECK(ipc_message_loop_->BelongsToCurrentThread()); DCHECK_EQ(state_, STATE_OPENING); @@ -90,6 +96,29 @@ void P2PSocketClient::DeliverOnSocketCreated(const net::IPEndPoint& address) { delegate_->OnOpen(address); } +void P2PSocketClient::OnIncomingTcpConnection(const net::IPEndPoint& address) { + DCHECK(ipc_message_loop_->BelongsToCurrentThread()); + DCHECK_EQ(state_, STATE_OPEN); + + scoped_refptr<P2PSocketClient> new_client = new P2PSocketClient(dispatcher_); + new_client->socket_id_ = dispatcher_->RegisterClient(new_client); + new_client->state_ = STATE_OPEN; + new_client->delegate_message_loop_ = delegate_message_loop_; + + dispatcher_->SendP2PMessage(new P2PHostMsg_AcceptIncomingTcpConnection( + 0, socket_id_, address, new_client->socket_id_)); + + delegate_message_loop_->PostTask(FROM_HERE, NewRunnableMethod( + this, &P2PSocketClient::DeliverOnIncomingTcpConnection, + address, new_client)); +} + +void P2PSocketClient::DeliverOnIncomingTcpConnection( + const net::IPEndPoint& address, scoped_refptr<P2PSocketClient> new_client) { + if (delegate_) + delegate_->OnIncomingTcpConnection(address, new_client); +} + void P2PSocketClient::OnError() { DCHECK(ipc_message_loop_->BelongsToCurrentThread()); state_ = STATE_ERROR; diff --git a/content/renderer/p2p/socket_client.h b/content/renderer/p2p/socket_client.h index 82343e1..fe3f691 100644 --- a/content/renderer/p2p/socket_client.h +++ b/content/renderer/p2p/socket_client.h @@ -31,6 +31,8 @@ class P2PSocketClient : public base::RefCountedThreadSafe<P2PSocketClient> { virtual ~Delegate() { } virtual void OnOpen(const net::IPEndPoint& address) = 0; + virtual void OnIncomingTcpConnection(const net::IPEndPoint& address, + P2PSocketClient* client) = 0; virtual void OnError() = 0; virtual void OnDataReceived(const net::IPEndPoint& address, const std::vector<char>& data) = 0; @@ -41,7 +43,9 @@ class P2PSocketClient : public base::RefCountedThreadSafe<P2PSocketClient> { // Initialize socket of the specified |type| and connected to the // specified |address|. |address| matters only when |type| is set to // P2P_SOCKET_TCP_CLIENT. - void Init(P2PSocketType type, const net::IPEndPoint& address, + void Init(P2PSocketType type, + const net::IPEndPoint& local_address, + const net::IPEndPoint& remote_address, Delegate* delegate, scoped_refptr<base::MessageLoopProxy> delegate_loop); @@ -54,6 +58,8 @@ class P2PSocketClient : public base::RefCountedThreadSafe<P2PSocketClient> { int socket_id() const { return socket_id_; } + void set_delegate(Delegate* delegate); + private: enum State { STATE_UNINITIALIZED, @@ -72,12 +78,16 @@ class P2PSocketClient : public base::RefCountedThreadSafe<P2PSocketClient> { // Message handlers that run on IPC thread. void OnSocketCreated(const net::IPEndPoint& address); + void OnIncomingTcpConnection(const net::IPEndPoint& address); void OnError(); void OnDataReceived(const net::IPEndPoint& address, const std::vector<char>& data); // Proxy methods that deliver messages to the delegate thread. void DeliverOnSocketCreated(const net::IPEndPoint& address); + void DeliverOnIncomingTcpConnection( + const net::IPEndPoint& address, + scoped_refptr<P2PSocketClient> new_client); void DeliverOnError(); void DeliverOnDataReceived(const net::IPEndPoint& address, const std::vector<char>& data); @@ -85,7 +95,6 @@ class P2PSocketClient : public base::RefCountedThreadSafe<P2PSocketClient> { // Scheduled on the IPC thread to finish closing the connection. void DoClose(); - // Called by the dispatcher when it is destroyed. void Detach(); diff --git a/content/renderer/p2p/socket_dispatcher.cc b/content/renderer/p2p/socket_dispatcher.cc index 8ea729c..c69d057 100644 --- a/content/renderer/p2p/socket_dispatcher.cc +++ b/content/renderer/p2p/socket_dispatcher.cc @@ -23,6 +23,7 @@ bool P2PSocketDispatcher::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(P2PSocketDispatcher, message) IPC_MESSAGE_HANDLER(P2PMsg_OnSocketCreated, OnSocketCreated) + IPC_MESSAGE_HANDLER(P2PMsg_OnIncomingTcpConnection, OnIncomingTcpConnection) IPC_MESSAGE_HANDLER(P2PMsg_OnError, OnError) IPC_MESSAGE_HANDLER(P2PMsg_OnDataReceived, OnDataReceived) IPC_MESSAGE_UNHANDLED(handled = false) @@ -55,6 +56,14 @@ void P2PSocketDispatcher::OnSocketCreated( } } +void P2PSocketDispatcher::OnIncomingTcpConnection( + int socket_id, const net::IPEndPoint& address) { + P2PSocketClient* client = GetClient(socket_id); + if (client) { + client->OnIncomingTcpConnection(address); + } +} + void P2PSocketDispatcher::OnError(int socket_id) { P2PSocketClient* client = GetClient(socket_id); if (client) { diff --git a/content/renderer/p2p/socket_dispatcher.h b/content/renderer/p2p/socket_dispatcher.h index acc5ef5..8ff1e1c 100644 --- a/content/renderer/p2p/socket_dispatcher.h +++ b/content/renderer/p2p/socket_dispatcher.h @@ -56,6 +56,7 @@ class P2PSocketDispatcher : public RenderViewObserver { // Incoming message handlers. void OnSocketCreated(int socket_id, const net::IPEndPoint& address); + void OnIncomingTcpConnection(int socket_id, const net::IPEndPoint& address); void OnError(int socket_id); void OnDataReceived(int socket_id, const net::IPEndPoint& address, const std::vector<char>& data); |