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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "net/base/ip_endpoint.h" | 11 #include "net/base/ip_endpoint.h" |
12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
13 #include "net/base/net_log.h" | 13 #include "net/base/net_log.h" |
14 #include "net/base/net_util.h" | |
mmenke
2014/05/23 19:20:58
What is this needed for?
byungchul
2014/05/30 00:19:02
Done.
| |
14 #include "net/socket/server_socket.h" | 15 #include "net/socket/server_socket.h" |
15 #include "net/socket/tcp_socket.h" | 16 #include "net/socket/tcp_socket.h" |
16 | 17 |
17 namespace net { | 18 namespace net { |
18 | 19 |
19 class NET_EXPORT_PRIVATE TCPServerSocket : public ServerSocket { | 20 class NET_EXPORT_PRIVATE TCPServerSocket : public ServerSocket { |
20 public: | 21 public: |
21 TCPServerSocket(NetLog* net_log, const NetLog::Source& source); | 22 TCPServerSocket(NetLog* net_log, const NetLog::Source& source); |
22 virtual ~TCPServerSocket(); | 23 virtual ~TCPServerSocket(); |
23 | 24 |
24 // net::ServerSocket implementation. | 25 // net::ServerSocket implementation. |
25 virtual int Listen(const IPEndPoint& address, int backlog) OVERRIDE; | 26 virtual int Listen(const IPEndPoint& address, int backlog) OVERRIDE; |
26 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; | 27 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; |
27 virtual int Accept(scoped_ptr<StreamSocket>* socket, | 28 virtual int Accept(scoped_ptr<StreamSocket>* socket, |
28 const CompletionCallback& callback) OVERRIDE; | 29 const CompletionCallback& callback) OVERRIDE; |
29 | 30 |
31 // Factory with IP address string and port. | |
32 static scoped_ptr<TCPServerSocket> Create(const std::string& ip, int port); | |
mmenke
2014/05/23 19:20:58
I think it's kinda of weird to have TCPServerSocke
byungchul
2014/05/30 00:19:02
Defined ServerSocketFactory which is necessary to
| |
33 | |
30 private: | 34 private: |
31 // Converts |accepted_socket_| and stores the result in | 35 // Converts |accepted_socket_| and stores the result in |
32 // |output_accepted_socket|. | 36 // |output_accepted_socket|. |
33 // |output_accepted_socket| is untouched on failure. But |accepted_socket_| is | 37 // |output_accepted_socket| is untouched on failure. But |accepted_socket_| is |
34 // set to NULL in any case. | 38 // set to NULL in any case. |
35 int ConvertAcceptedSocket(int result, | 39 int ConvertAcceptedSocket(int result, |
36 scoped_ptr<StreamSocket>* output_accepted_socket); | 40 scoped_ptr<StreamSocket>* output_accepted_socket); |
37 // Completion callback for calling TCPSocket::Accept(). | 41 // Completion callback for calling TCPSocket::Accept(). |
38 void OnAcceptCompleted(scoped_ptr<StreamSocket>* output_accepted_socket, | 42 void OnAcceptCompleted(scoped_ptr<StreamSocket>* output_accepted_socket, |
39 const CompletionCallback& forward_callback, | 43 const CompletionCallback& forward_callback, |
40 int result); | 44 int result); |
41 | 45 |
42 TCPSocket socket_; | 46 TCPSocket socket_; |
43 | 47 |
44 scoped_ptr<TCPSocket> accepted_socket_; | 48 scoped_ptr<TCPSocket> accepted_socket_; |
45 IPEndPoint accepted_address_; | 49 IPEndPoint accepted_address_; |
46 bool pending_accept_; | 50 bool pending_accept_; |
47 | 51 |
48 DISALLOW_COPY_AND_ASSIGN(TCPServerSocket); | 52 DISALLOW_COPY_AND_ASSIGN(TCPServerSocket); |
49 }; | 53 }; |
50 | 54 |
51 } // namespace net | 55 } // namespace net |
52 | 56 |
53 #endif // NET_SOCKET_TCP_SERVER_SOCKET_H_ | 57 #endif // NET_SOCKET_TCP_SERVER_SOCKET_H_ |
OLD | NEW |