OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" | 10 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
11 #include "content/common/p2p_messages.h" | 11 #include "content/common/p2p_messages.h" |
12 #include "net/base/address_list.h" | 12 #include "net/base/address_list.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
15 #include "net/socket/stream_socket.h" | 15 #include "net/socket/stream_socket.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 const int kListenBacklog = 5; | 18 const int kListenBacklog = 5; |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 P2PSocketHostTcpServer::P2PSocketHostTcpServer( | 23 P2PSocketHostTcpServer::P2PSocketHostTcpServer( |
24 IPC::Message::Sender* message_sender, | 24 IPC::Sender* message_sender, |
25 int routing_id, int id) | 25 int routing_id, int id) |
26 : P2PSocketHost(message_sender, routing_id, id), | 26 : P2PSocketHost(message_sender, routing_id, id), |
27 socket_(new net::TCPServerSocket(NULL, net::NetLog::Source())), | 27 socket_(new net::TCPServerSocket(NULL, net::NetLog::Source())), |
28 ALLOW_THIS_IN_INITIALIZER_LIST(accept_callback_( | 28 ALLOW_THIS_IN_INITIALIZER_LIST(accept_callback_( |
29 base::Bind(&P2PSocketHostTcpServer::OnAccepted, | 29 base::Bind(&P2PSocketHostTcpServer::OnAccepted, |
30 base::Unretained(this)))) { | 30 base::Unretained(this)))) { |
31 } | 31 } |
32 | 32 |
33 P2PSocketHostTcpServer::~P2PSocketHostTcpServer() { | 33 P2PSocketHostTcpServer::~P2PSocketHostTcpServer() { |
34 STLDeleteContainerPairSecondPointers(accepted_sockets_.begin(), | 34 STLDeleteContainerPairSecondPointers(accepted_sockets_.begin(), |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 accepted_sockets_.erase(it); | 131 accepted_sockets_.erase(it); |
132 scoped_ptr<P2PSocketHostTcp> result( | 132 scoped_ptr<P2PSocketHostTcp> result( |
133 new P2PSocketHostTcp(message_sender_, routing_id_, id)); | 133 new P2PSocketHostTcp(message_sender_, routing_id_, id)); |
134 if (!result->InitAccepted(remote_address, socket)) | 134 if (!result->InitAccepted(remote_address, socket)) |
135 return NULL; | 135 return NULL; |
136 | 136 |
137 return result.release(); | 137 return result.release(); |
138 } | 138 } |
139 | 139 |
140 } // namespace content | 140 } // namespace content |
OLD | NEW |