Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: net/socket/tcp_server_socket.h

Issue 2815993002: Adds a method to TCPServerSocket to adopt a socket. (Closed)
Patch Set: Fixed (I hope) Windows compile failure. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/socket/tcp_server_socket.cc » ('j') | net/socket/tcp_server_socket.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/tcp_socket.h" 14 #include "net/socket/tcp_socket.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 class NetLog; 18 class NetLog;
19 struct NetLogSource; 19 struct NetLogSource;
20 20
21 // A server socket that uses TCP as the transport layer. 21 // A server socket that uses TCP as the transport layer.
22 class NET_EXPORT TCPServerSocket : public ServerSocket { 22 class NET_EXPORT TCPServerSocket : public ServerSocket {
23 public: 23 public:
24 TCPServerSocket(NetLog* net_log, const NetLogSource& source); 24 TCPServerSocket(NetLog* net_log, const NetLogSource& source);
25 ~TCPServerSocket() override; 25 ~TCPServerSocket() override;
26 26
27 #if defined(OS_POSIX)
28 // Takes ownership of |socket_fd|, which is assumed to be already open, bound
29 // and listening, potentially with a connection already waiting to be
30 // accepted. This is used by headless chrome to allow a parent process to open
31 // a port and listen on it, pass it to Chrome on launch to use as the devtools
32 // remote debugging port, then connect to it immediately and block on the
33 // first read rather than having to poll for the connection. See
34 // crbug.com/624837.
35 int AdopListeningRawSocket(int socket_fd);
Jana 2017/04/17 17:27:57 Use "Adopt" instead of "Adop".
Raul Vera 2017/04/17 23:51:57 Oops. Thanks. Done.
36 #endif
mmenke 2017/04/17 17:42:18 Why do we need a POSIX-only method? net/ is suppo
Raul Vera 2017/04/17 23:51:57 Because Windows does not inherit sockets the same
mmenke 2017/04/18 16:15:24 I don't think this is relevant to code in net/, wh
37
27 // net::ServerSocket implementation. 38 // net::ServerSocket implementation.
28 int Listen(const IPEndPoint& address, int backlog) override; 39 int Listen(const IPEndPoint& address, int backlog) override;
29 int GetLocalAddress(IPEndPoint* address) const override; 40 int GetLocalAddress(IPEndPoint* address) const override;
30 int Accept(std::unique_ptr<StreamSocket>* socket, 41 int Accept(std::unique_ptr<StreamSocket>* socket,
31 const CompletionCallback& callback) override; 42 const CompletionCallback& callback) override;
32 43
33 // Detachs from the current thread, to allow the socket to be transferred to 44 // 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 45 // a new thread. Should only be called when the object is no longer used by
35 // the old thread. 46 // the old thread.
36 void DetachFromThread(); 47 void DetachFromThread();
(...skipping 16 matching lines...) Expand all
53 std::unique_ptr<TCPSocket> accepted_socket_; 64 std::unique_ptr<TCPSocket> accepted_socket_;
54 IPEndPoint accepted_address_; 65 IPEndPoint accepted_address_;
55 bool pending_accept_; 66 bool pending_accept_;
56 67
57 DISALLOW_COPY_AND_ASSIGN(TCPServerSocket); 68 DISALLOW_COPY_AND_ASSIGN(TCPServerSocket);
58 }; 69 };
59 70
60 } // namespace net 71 } // namespace net
61 72
62 #endif // NET_SOCKET_TCP_SERVER_SOCKET_H_ 73 #endif // NET_SOCKET_TCP_SERVER_SOCKET_H_
OLDNEW
« no previous file with comments | « no previous file | net/socket/tcp_server_socket.cc » ('j') | net/socket/tcp_server_socket.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698