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

Side by Side Diff: net/socket/tcp_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_SOCKET_POSIX_H_ 5 #ifndef NET_SOCKET_TCP_SOCKET_POSIX_H_
6 #define NET_SOCKET_TCP_SOCKET_POSIX_H_ 6 #define NET_SOCKET_TCP_SOCKET_POSIX_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "net/base/address_family.h" 15 #include "net/base/address_family.h"
16 #include "net/base/completion_callback.h" 16 #include "net/base/completion_callback.h"
17 #include "net/base/net_export.h" 17 #include "net/base/net_export.h"
18 #include "net/log/net_log_with_source.h" 18 #include "net/log/net_log_with_source.h"
19 #include "net/socket/socket_descriptor.h"
19 #include "net/socket/socket_performance_watcher.h" 20 #include "net/socket/socket_performance_watcher.h"
20 21
21 namespace base { 22 namespace base {
22 class TimeDelta; 23 class TimeDelta;
23 } 24 }
24 25
25 namespace net { 26 namespace net {
26 27
27 class AddressList; 28 class AddressList;
28 class IOBuffer; 29 class IOBuffer;
29 class IPEndPoint; 30 class IPEndPoint;
30 class SocketPosix; 31 class SocketPosix;
31 class NetLog; 32 class NetLog;
32 struct NetLogSource; 33 struct NetLogSource;
33 34
34 class NET_EXPORT TCPSocketPosix { 35 class NET_EXPORT TCPSocketPosix {
35 public: 36 public:
36 // |socket_performance_watcher| is notified of the performance metrics related 37 // |socket_performance_watcher| is notified of the performance metrics related
37 // to this socket. |socket_performance_watcher| may be null. 38 // to this socket. |socket_performance_watcher| may be null.
38 TCPSocketPosix( 39 TCPSocketPosix(
39 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, 40 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
40 NetLog* net_log, 41 NetLog* net_log,
41 const NetLogSource& source); 42 const NetLogSource& source);
42 virtual ~TCPSocketPosix(); 43 virtual ~TCPSocketPosix();
43 44
44 int Open(AddressFamily family); 45 int Open(AddressFamily family);
45 46
46 // Takes ownership of |socket_fd|. 47 // Takes ownership of |socket|, which is known to already be connected to the
47 int AdoptConnectedSocket(int socket_fd, const IPEndPoint& peer_address); 48 // given peer address. However, peer address may be the empty address, for
49 // compatibility. The given peer address will be returned by GetPeerAddress.
50 int AdoptConnectedSocket(SocketDescriptor socket,
51 const IPEndPoint& peer_address);
52 // Takes ownership of |socket|, which may or may not be open, bound, or
53 // listening. The caller must determine the state of the socket based on its
54 // provenance and act accordingly.
55 int AdoptUnconnectedSocket(SocketDescriptor socket);
48 56
49 int Bind(const IPEndPoint& address); 57 int Bind(const IPEndPoint& address);
50 58
51 int Listen(int backlog); 59 int Listen(int backlog);
52 int Accept(std::unique_ptr<TCPSocketPosix>* socket, 60 int Accept(std::unique_ptr<TCPSocketPosix>* socket,
53 IPEndPoint* address, 61 IPEndPoint* address,
54 const CompletionCallback& callback); 62 const CompletionCallback& callback);
55 63
56 int Connect(const IPEndPoint& address, const CompletionCallback& callback); 64 int Connect(const IPEndPoint& address, const CompletionCallback& callback);
57 bool IsConnected() const; 65 bool IsConnected() const;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 bool logging_multiple_connect_attempts_; 250 bool logging_multiple_connect_attempts_;
243 251
244 NetLogWithSource net_log_; 252 NetLogWithSource net_log_;
245 253
246 DISALLOW_COPY_AND_ASSIGN(TCPSocketPosix); 254 DISALLOW_COPY_AND_ASSIGN(TCPSocketPosix);
247 }; 255 };
248 256
249 } // namespace net 257 } // namespace net
250 258
251 #endif // NET_SOCKET_TCP_SOCKET_POSIX_H_ 259 #endif // NET_SOCKET_TCP_SOCKET_POSIX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698