Index: content/renderer/p2p/ipc_socket_factory.cc |
diff --git a/content/renderer/p2p/ipc_socket_factory.cc b/content/renderer/p2p/ipc_socket_factory.cc |
index 43b6d163ff45764531e99837c3222f8e9547f175..7f181d517d7d4935708f4e2f51f22745cf4c566f 100644 |
--- a/content/renderer/p2p/ipc_socket_factory.cc |
+++ b/content/renderer/p2p/ipc_socket_factory.cc |
@@ -93,7 +93,8 @@ class IpcPacketSocket : public talk_base::AsyncPacketSocket, |
virtual void SetError(int error) OVERRIDE; |
// P2PSocketClientDelegate implementation. |
- virtual void OnOpen(const net::IPEndPoint& address) OVERRIDE; |
+ virtual void OnOpen(const net::IPEndPoint& address, |
+ const net::IPEndPoint& remote_address) OVERRIDE; |
virtual void OnIncomingTcpConnection( |
const net::IPEndPoint& address, |
P2PSocketClient* client) OVERRIDE; |
@@ -233,10 +234,14 @@ bool IpcPacketSocket::Init(P2PSocketType type, |
return false; |
} |
+ if (remote_address.IsNil()) { |
+ return false; |
+ } |
+ |
net::IPEndPoint remote_endpoint; |
- if (!remote_address.IsNil() && |
- !jingle_glue::SocketAddressToIPEndPoint( |
- remote_address, &remote_endpoint)) { |
+ if (!jingle_glue::SocketAddressToIPEndPoint( |
+ remote_address, &remote_endpoint) && !IsTcpClientSocket(type_)) { |
+ // Non TCP sockets must have a resolved remote address. |
return false; |
} |
@@ -426,7 +431,8 @@ void IpcPacketSocket::SetError(int error) { |
error_ = error; |
} |
-void IpcPacketSocket::OnOpen(const net::IPEndPoint& address) { |
+void IpcPacketSocket::OnOpen(const net::IPEndPoint& address, |
+ const net::IPEndPoint& remote_address) { |
DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
if (!jingle_glue::IPEndPointToSocketAddress(address, &local_address_)) { |
@@ -446,8 +452,21 @@ void IpcPacketSocket::OnOpen(const net::IPEndPoint& address) { |
} |
SignalAddressReady(this, local_address_); |
- if (IsTcpClientSocket(type_)) |
+ if (IsTcpClientSocket(type_)) { |
SignalConnect(this); |
+ // If remote address is unresolved, set resolved remote IP address received |
+ // in the callback. This address will be used while sending the packets |
+ // over the network. |
+ if (remote_address_.IsUnresolvedIP()) { |
+ talk_base::SocketAddress jingle_socket_address; |
+ if (!jingle_glue::IPEndPointToSocketAddress( |
+ remote_address, &jingle_socket_address)) { |
+ NOTREACHED(); |
+ } |
+ // Set only the IP address. |
+ remote_address_.SetResolvedIP(jingle_socket_address.ipaddr()); |
+ } |
+ } |
} |
void IpcPacketSocket::OnIncomingTcpConnection( |