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

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

Issue 2815993002: Adds a method to TCPServerSocket to adopt a socket. (Closed)
Patch Set: Refined GetSocketDescriptor per review. Created 3 years, 7 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 | « device/bluetooth/bluetooth_socket_win.cc ('k') | net/socket/socket_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
41 // provenance and act accordingly. The socket may have connections waiting
42 // to be accepted, but must not be actually connected.
43 int AdoptUnconnectedSocket(SocketDescriptor socket);
44
37 // Releases ownership of |socket_fd_| to caller. 45 // Releases ownership of |socket_fd_| to caller.
38 SocketDescriptor ReleaseConnectedSocket(); 46 SocketDescriptor ReleaseConnectedSocket();
39 47
40 int Bind(const SockaddrStorage& address); 48 int Bind(const SockaddrStorage& address);
41 49
42 int Listen(int backlog); 50 int Listen(int backlog);
43 int Accept(std::unique_ptr<SocketPosix>* socket, 51 int Accept(std::unique_ptr<SocketPosix>* socket,
44 const CompletionCallback& callback); 52 const CompletionCallback& callback);
45 53
46 // Connects socket. On non-ERR_IO_PENDING error, sets errno and returns a net 54 // 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_; 148 std::unique_ptr<SockaddrStorage> peer_address_;
141 149
142 base::ThreadChecker thread_checker_; 150 base::ThreadChecker thread_checker_;
143 151
144 DISALLOW_COPY_AND_ASSIGN(SocketPosix); 152 DISALLOW_COPY_AND_ASSIGN(SocketPosix);
145 }; 153 };
146 154
147 } // namespace net 155 } // namespace net
148 156
149 #endif // NET_SOCKET_SOCKET_POSIX_H_ 157 #endif // NET_SOCKET_SOCKET_POSIX_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_socket_win.cc ('k') | net/socket/socket_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698