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

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

Issue 2815993002: Adds a method to TCPServerSocket to adopt a socket. (Closed)
Patch Set: Rebased to fix merge conflict 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SOCKET_POSIX_H_ 5 #ifndef NET_SOCKET_SOCKET_POSIX_H_
6 #define NET_SOCKET_SOCKET_POSIX_H_ 6 #define NET_SOCKET_SOCKET_POSIX_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 13 matching lines...) Expand all
24 // Socket class to provide asynchronous read/write operations on top of the 24 // Socket class to provide asynchronous read/write operations on top of the
25 // posix socket api. It supports AF_INET, AF_INET6, and AF_UNIX addresses. 25 // posix socket api. It supports AF_INET, AF_INET6, and AF_UNIX addresses.
26 class NET_EXPORT_PRIVATE SocketPosix : public base::MessageLoopForIO::Watcher { 26 class NET_EXPORT_PRIVATE SocketPosix : public base::MessageLoopForIO::Watcher {
27 public: 27 public:
28 SocketPosix(); 28 SocketPosix();
29 ~SocketPosix() override; 29 ~SocketPosix() override;
30 30
31 // Opens a socket and returns net::OK if |address_family| is AF_INET, AF_INET6 31 // Opens a socket and returns net::OK if |address_family| is AF_INET, AF_INET6
32 // or AF_UNIX. Otherwise, it does DCHECK() and returns a net error. 32 // or AF_UNIX. Otherwise, it does DCHECK() and returns a net error.
33 int Open(int address_family); 33 int Open(int address_family);
34 // Takes ownership of |socket|. 34
35 // Takes ownership of |socket|, which is known to already be connected to the
36 // given peer address.
35 int AdoptConnectedSocket(SocketDescriptor socket, 37 int AdoptConnectedSocket(SocketDescriptor socket,
36 const SockaddrStorage& peer_address); 38 const SockaddrStorage& peer_address);
39 // Takes ownership of |socket|, which may or may not be open, bound, or
40 // listening. The caller must determine the state of the socket based on its
mmenke 2017/04/21 19:20:38 Since it may be open (Or may not), maybe just call
Raul Vera 2017/05/01 05:35:25 But that loses the symmetry with AdoptConnectedSoc
41 // provenance and act accordingly.
42 int AdoptUnconnectedSocket(SocketDescriptor socket);
43
37 // Releases ownership of |socket_fd_| to caller. 44 // Releases ownership of |socket_fd_| to caller.
38 SocketDescriptor ReleaseConnectedSocket(); 45 SocketDescriptor ReleaseConnectedSocket();
39 46
40 int Bind(const SockaddrStorage& address); 47 int Bind(const SockaddrStorage& address);
41 48
42 int Listen(int backlog); 49 int Listen(int backlog);
43 int Accept(std::unique_ptr<SocketPosix>* socket, 50 int Accept(std::unique_ptr<SocketPosix>* socket,
44 const CompletionCallback& callback); 51 const CompletionCallback& callback);
45 52
46 // Connects socket. On non-ERR_IO_PENDING error, sets errno and returns a net 53 // Connects socket. On non-ERR_IO_PENDING error, sets errno and returns a net
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 std::unique_ptr<SockaddrStorage> peer_address_; 147 std::unique_ptr<SockaddrStorage> peer_address_;
141 148
142 base::ThreadChecker thread_checker_; 149 base::ThreadChecker thread_checker_;
143 150
144 DISALLOW_COPY_AND_ASSIGN(SocketPosix); 151 DISALLOW_COPY_AND_ASSIGN(SocketPosix);
145 }; 152 };
146 153
147 } // namespace net 154 } // namespace net
148 155
149 #endif // NET_SOCKET_SOCKET_POSIX_H_ 156 #endif // NET_SOCKET_SOCKET_POSIX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698