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 #ifndef NET_SOCKET_TCP_SERVER_SOCKET_H_ | 5 #ifndef NET_SOCKET_TCP_SERVER_SOCKET_H_ |
6 #define NET_SOCKET_TCP_SERVER_SOCKET_H_ | 6 #define NET_SOCKET_TCP_SERVER_SOCKET_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "base/basictypes.h" |
9 | 9 #include "base/compiler_specific.h" |
10 #if defined(OS_WIN) | 10 #include "base/memory/scoped_ptr.h" |
11 #include "net/socket/tcp_server_socket_win.h" | 11 #include "net/base/ip_endpoint.h" |
12 #elif defined(OS_POSIX) | 12 #include "net/base/net_export.h" |
13 #include "net/socket/tcp_server_socket_libevent.h" | 13 #include "net/base/net_log.h" |
14 #endif | 14 #include "net/socket/server_socket.h" |
15 #include "net/socket/tcp_socket.h" | |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 #if defined(OS_WIN) | 19 class NET_EXPORT_PRIVATE TCPServerSocket : public ServerSocket { |
19 typedef TCPServerSocketWin TCPServerSocket; | 20 public: |
20 #elif defined(OS_POSIX) | 21 TCPServerSocket(NetLog* net_log, const NetLog::Source& source); |
21 typedef TCPServerSocketLibevent TCPServerSocket; | 22 virtual ~TCPServerSocket(); |
22 #endif | 23 |
24 // net::ServerSocket implementation. | |
25 virtual int Listen(const IPEndPoint& address, int backlog) OVERRIDE; | |
26 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; | |
27 virtual int Accept(scoped_ptr<StreamSocket>* socket, | |
28 const CompletionCallback& callback) OVERRIDE; | |
29 | |
30 private: | |
31 // Completion callback for calling TCPSocket::Accept(). It converts the output | |
32 // of TCPSocket::Accept() to that of TCPServerSocket::Accept(). | |
33 void OnAcceptCompleted(scoped_ptr<StreamSocket>* output_accepted_socket, | |
akalin
2013/08/26 23:48:51
put output param last (and probably don't need to
yzshen1
2013/08/27 17:36:56
We cannot, because we use this method in a base::B
| |
34 const CompletionCallback& forward_callback, | |
35 int result); | |
36 TCPSocket socket_; | |
37 | |
38 scoped_ptr<TCPSocket> accepted_socket_; | |
39 IPEndPoint accepted_address_; | |
40 bool pending_accept_; | |
41 | |
42 DISALLOW_COPY_AND_ASSIGN(TCPServerSocket); | |
43 }; | |
23 | 44 |
24 } // namespace net | 45 } // namespace net |
25 | 46 |
26 #endif // NET_SOCKET_TCP_SERVER_SOCKET_H_ | 47 #endif // NET_SOCKET_TCP_SERVER_SOCKET_H_ |
OLD | NEW |