Chromium Code Reviews| 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. | |
| 31 int AdoptUnconnectedSocket(SocketDescriptor socket); | |
|
mmenke
2017/04/21 19:20:38
This works for connected sockets, too, right? May
Raul Vera
2017/05/01 05:35:25
It doesn't work for connected sockets, as the peer
| |
| 32 | |
| 27 // net::ServerSocket implementation. | 33 // net::ServerSocket implementation. |
| 28 int Listen(const IPEndPoint& address, int backlog) override; | 34 int Listen(const IPEndPoint& address, int backlog) override; |
| 29 int GetLocalAddress(IPEndPoint* address) const override; | 35 int GetLocalAddress(IPEndPoint* address) const override; |
| 30 int Accept(std::unique_ptr<StreamSocket>* socket, | 36 int Accept(std::unique_ptr<StreamSocket>* socket, |
| 31 const CompletionCallback& callback) override; | 37 const CompletionCallback& callback) override; |
| 32 | 38 |
| 33 // Detachs from the current thread, to allow the socket to be transferred to | 39 // 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 | 40 // a new thread. Should only be called when the object is no longer used by |
| 35 // the old thread. | 41 // the old thread. |
| 36 void DetachFromThread(); | 42 void DetachFromThread(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 53 std::unique_ptr<TCPSocket> accepted_socket_; | 59 std::unique_ptr<TCPSocket> accepted_socket_; |
| 54 IPEndPoint accepted_address_; | 60 IPEndPoint accepted_address_; |
| 55 bool pending_accept_; | 61 bool pending_accept_; |
| 56 | 62 |
| 57 DISALLOW_COPY_AND_ASSIGN(TCPServerSocket); | 63 DISALLOW_COPY_AND_ASSIGN(TCPServerSocket); |
| 58 }; | 64 }; |
| 59 | 65 |
| 60 } // namespace net | 66 } // namespace net |
| 61 | 67 |
| 62 #endif // NET_SOCKET_TCP_SERVER_SOCKET_H_ | 68 #endif // NET_SOCKET_TCP_SERVER_SOCKET_H_ |
| OLD | NEW |