OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "content/renderer/p2p/ipc_socket_factory.h" | 5 #include "content/renderer/p2p/ipc_socket_factory.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "content/renderer/p2p/socket_client.h" | 10 #include "content/renderer/p2p/socket_client.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 256 |
257 void IpcPacketSocket::OnOpen(const net::IPEndPoint& address) { | 257 void IpcPacketSocket::OnOpen(const net::IPEndPoint& address) { |
258 DCHECK_EQ(MessageLoop::current(), message_loop_); | 258 DCHECK_EQ(MessageLoop::current(), message_loop_); |
259 | 259 |
260 if (!jingle_glue::IPEndPointToSocketAddress(address, &local_address_)) { | 260 if (!jingle_glue::IPEndPointToSocketAddress(address, &local_address_)) { |
261 // Always expect correct IPv4 address to be allocated. | 261 // Always expect correct IPv4 address to be allocated. |
262 NOTREACHED(); | 262 NOTREACHED(); |
263 OnError(); | 263 OnError(); |
264 return; | 264 return; |
265 } | 265 } |
| 266 |
| 267 state_ = IS_OPEN; |
| 268 |
266 SignalAddressReady(this, local_address_); | 269 SignalAddressReady(this, local_address_); |
267 if (type_ == P2P_SOCKET_TCP_CLIENT) | 270 if (type_ == P2P_SOCKET_TCP_CLIENT) |
268 SignalConnect(this); | 271 SignalConnect(this); |
269 state_ = IS_OPEN; | |
270 } | 272 } |
271 | 273 |
272 void IpcPacketSocket::OnIncomingTcpConnection( | 274 void IpcPacketSocket::OnIncomingTcpConnection( |
273 const net::IPEndPoint& address, | 275 const net::IPEndPoint& address, |
274 P2PSocketClient* client) { | 276 P2PSocketClient* client) { |
275 DCHECK_EQ(MessageLoop::current(), message_loop_); | 277 DCHECK_EQ(MessageLoop::current(), message_loop_); |
276 | 278 |
277 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); | 279 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); |
278 | 280 |
279 talk_base::SocketAddress remote_address; | 281 talk_base::SocketAddress remote_address; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 talk_base::SocketAddress crome_address; | 361 talk_base::SocketAddress crome_address; |
360 P2PSocketClient* socket_client = new P2PSocketClient(socket_dispatcher_); | 362 P2PSocketClient* socket_client = new P2PSocketClient(socket_dispatcher_); |
361 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); | 363 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); |
362 if (!socket->Init(P2P_SOCKET_TCP_CLIENT, socket_client, local_address, | 364 if (!socket->Init(P2P_SOCKET_TCP_CLIENT, socket_client, local_address, |
363 remote_address)) | 365 remote_address)) |
364 return NULL; | 366 return NULL; |
365 return socket.release(); | 367 return socket.release(); |
366 } | 368 } |
367 | 369 |
368 } // namespace content | 370 } // namespace content |
OLD | NEW |