| 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/browser/renderer_host/p2p/socket_host_tcp_server.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h" |
| 6 | 6 |
| 7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
| 8 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" | 8 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
| 9 #include "content/common/p2p_messages.h" | 9 #include "content/common/p2p_messages.h" |
| 10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
| 11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
| 12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
| 13 #include "net/base/sys_addrinfo.h" | 13 #include "net/base/sys_addrinfo.h" |
| 14 #include "net/socket/client_socket.h" | 14 #include "net/socket/stream_socket.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 const int kListenBacklog = 5; | 17 const int kListenBacklog = 5; |
| 18 } // namespace | 18 } // namespace |
| 19 | 19 |
| 20 P2PSocketHostTcpServer::P2PSocketHostTcpServer( | 20 P2PSocketHostTcpServer::P2PSocketHostTcpServer( |
| 21 IPC::Message::Sender* message_sender, | 21 IPC::Message::Sender* message_sender, |
| 22 int routing_id, int id) | 22 int routing_id, int id) |
| 23 : P2PSocketHost(message_sender, routing_id, id), | 23 : P2PSocketHost(message_sender, routing_id, id), |
| 24 socket_(new net::TCPServerSocket(NULL, net::NetLog::Source())), | 24 socket_(new net::TCPServerSocket(NULL, net::NetLog::Source())), |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 NOTREACHED(); | 119 NOTREACHED(); |
| 120 OnError(); | 120 OnError(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 P2PSocketHost* P2PSocketHostTcpServer::AcceptIncomingTcpConnection( | 123 P2PSocketHost* P2PSocketHostTcpServer::AcceptIncomingTcpConnection( |
| 124 const net::IPEndPoint& remote_address, int id) { | 124 const net::IPEndPoint& remote_address, int id) { |
| 125 AcceptedSocketsMap::iterator it = accepted_sockets_.find(remote_address); | 125 AcceptedSocketsMap::iterator it = accepted_sockets_.find(remote_address); |
| 126 if (it == accepted_sockets_.end()) | 126 if (it == accepted_sockets_.end()) |
| 127 return NULL; | 127 return NULL; |
| 128 | 128 |
| 129 net::ClientSocket* socket = it->second; | 129 net::StreamSocket* socket = it->second; |
| 130 accepted_sockets_.erase(it); | 130 accepted_sockets_.erase(it); |
| 131 scoped_ptr<P2PSocketHostTcp> result( | 131 scoped_ptr<P2PSocketHostTcp> result( |
| 132 new P2PSocketHostTcp(message_sender_, routing_id_, id)); | 132 new P2PSocketHostTcp(message_sender_, routing_id_, id)); |
| 133 if (!result->InitAccepted(remote_address, socket)) | 133 if (!result->InitAccepted(remote_address, socket)) |
| 134 return NULL; | 134 return NULL; |
| 135 | 135 |
| 136 return result.release(); | 136 return result.release(); |
| 137 } | 137 } |
| OLD | NEW |