| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.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/socket/server_socket.h" | 13 #include "net/socket/server_socket.h" |
| 14 #include "net/socket/socket_descriptor.h" |
| 14 #include "net/socket/tcp_socket.h" | 15 #include "net/socket/tcp_socket.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 class NetLog; | 19 class NetLog; |
| 19 struct NetLogSource; | 20 struct NetLogSource; |
| 20 | 21 |
| 21 // A server socket that uses TCP as the transport layer. | 22 // A server socket that uses TCP as the transport layer. |
| 22 class NET_EXPORT TCPServerSocket : public ServerSocket { | 23 class NET_EXPORT TCPServerSocket : public ServerSocket { |
| 23 public: | 24 public: |
| 24 TCPServerSocket(NetLog* net_log, const NetLogSource& source); | 25 TCPServerSocket(NetLog* net_log, const NetLogSource& source); |
| 25 ~TCPServerSocket() override; | 26 ~TCPServerSocket() override; |
| 26 | 27 |
| 28 // Takes ownership of |socket|, which has been opened, but may or may not be |
| 29 // bound or listening. The caller must determine this based on the provenance |
| 30 // of the socket and act accordingly. The socket may have connections waiting |
| 31 // to be accepted, but must not be actually connected. |
| 32 int AdoptSocket(SocketDescriptor socket); |
| 33 |
| 27 // net::ServerSocket implementation. | 34 // net::ServerSocket implementation. |
| 28 int Listen(const IPEndPoint& address, int backlog) override; | 35 int Listen(const IPEndPoint& address, int backlog) override; |
| 29 int GetLocalAddress(IPEndPoint* address) const override; | 36 int GetLocalAddress(IPEndPoint* address) const override; |
| 30 int Accept(std::unique_ptr<StreamSocket>* socket, | 37 int Accept(std::unique_ptr<StreamSocket>* socket, |
| 31 const CompletionCallback& callback) override; | 38 const CompletionCallback& callback) override; |
| 32 | 39 |
| 33 // Detachs from the current thread, to allow the socket to be transferred to | 40 // Detachs from the current thread, to allow the socket to be transferred to |
| 34 // a new thread. Should only be called when the object is no longer used by | 41 // a new thread. Should only be called when the object is no longer used by |
| 35 // the old thread. | 42 // the old thread. |
| 36 void DetachFromThread(); | 43 void DetachFromThread(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 std::unique_ptr<TCPSocket> accepted_socket_; | 60 std::unique_ptr<TCPSocket> accepted_socket_; |
| 54 IPEndPoint accepted_address_; | 61 IPEndPoint accepted_address_; |
| 55 bool pending_accept_; | 62 bool pending_accept_; |
| 56 | 63 |
| 57 DISALLOW_COPY_AND_ASSIGN(TCPServerSocket); | 64 DISALLOW_COPY_AND_ASSIGN(TCPServerSocket); |
| 58 }; | 65 }; |
| 59 | 66 |
| 60 } // namespace net | 67 } // namespace net |
| 61 | 68 |
| 62 #endif // NET_SOCKET_TCP_SERVER_SOCKET_H_ | 69 #endif // NET_SOCKET_TCP_SERVER_SOCKET_H_ |
| OLD | NEW |