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

Side by Side Diff: net/socket/tcp_socket_win.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_WIN_H_ 5 #ifndef NET_SOCKET_TCP_SOCKET_WIN_H_
6 #define NET_SOCKET_TCP_SOCKET_WIN_H_ 6 #define NET_SOCKET_TCP_SOCKET_WIN_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <winsock2.h> 9 #include <winsock2.h>
10 10
11 #include <memory> 11 #include <memory>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
17 #include "base/win/object_watcher.h" 17 #include "base/win/object_watcher.h"
18 #include "net/base/address_family.h" 18 #include "net/base/address_family.h"
19 #include "net/base/completion_callback.h" 19 #include "net/base/completion_callback.h"
20 #include "net/base/net_export.h" 20 #include "net/base/net_export.h"
21 #include "net/log/net_log_with_source.h" 21 #include "net/log/net_log_with_source.h"
22 #include "net/socket/socket_descriptor.h"
22 #include "net/socket/socket_performance_watcher.h" 23 #include "net/socket/socket_performance_watcher.h"
23 24
24 namespace net { 25 namespace net {
25 26
26 class AddressList; 27 class AddressList;
27 class IOBuffer; 28 class IOBuffer;
28 class IPEndPoint; 29 class IPEndPoint;
29 class NetLog; 30 class NetLog;
30 struct NetLogSource; 31 struct NetLogSource;
31 32
32 class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe), 33 class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe),
33 public base::win::ObjectWatcher::Delegate { 34 public base::win::ObjectWatcher::Delegate {
34 public: 35 public:
35 TCPSocketWin( 36 TCPSocketWin(
36 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, 37 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
37 NetLog* net_log, 38 NetLog* net_log,
38 const NetLogSource& source); 39 const NetLogSource& source);
39 ~TCPSocketWin() override; 40 ~TCPSocketWin() override;
40 41
41 int Open(AddressFamily family); 42 int Open(AddressFamily family);
42 43
43 // Both AdoptConnectedSocket and AdoptListenSocket take ownership of an 44 // Takes ownership of |socket|, which is known to already be connected to the
44 // existing socket. AdoptConnectedSocket takes an already connected 45 // given peer address. However, peer address may be the empty address, for
45 // socket. AdoptListenSocket takes a socket that is intended to accept 46 // compatibility. The given peer address will be returned by GetPeerAddress.
46 // connection. In some sense, AdoptListenSocket is more similar to Open. 47 int AdoptConnectedSocket(SocketDescriptor socket,
47 int AdoptConnectedSocket(SOCKET socket, const IPEndPoint& peer_address); 48 const SockaddrStorage& peer_address);
mmenke 2017/04/21 19:20:38 IPEndPoint
Raul Vera 2017/05/01 05:35:25 I guess you can tell I don't have a Windows machin
48 int AdoptListenSocket(SOCKET socket); 49 // Takes ownership of |socket|, which may or may not be open, bound, or
50 // listening. The caller must determine the state of the socket based on its
51 // provenance and act accordingly.
52 int AdoptUnconnectedSocket(SocketDescriptor socket);
49 53
50 int Bind(const IPEndPoint& address); 54 int Bind(const IPEndPoint& address);
51 55
52 int Listen(int backlog); 56 int Listen(int backlog);
53 int Accept(std::unique_ptr<TCPSocketWin>* socket, 57 int Accept(std::unique_ptr<TCPSocketWin>* socket,
54 IPEndPoint* address, 58 IPEndPoint* address,
55 const CompletionCallback& callback); 59 const CompletionCallback& callback);
56 60
57 int Connect(const IPEndPoint& address, const CompletionCallback& callback); 61 int Connect(const IPEndPoint& address, const CompletionCallback& callback);
58 bool IsConnected() const; 62 bool IsConnected() const;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 bool logging_multiple_connect_attempts_; 179 bool logging_multiple_connect_attempts_;
176 180
177 NetLogWithSource net_log_; 181 NetLogWithSource net_log_;
178 182
179 DISALLOW_COPY_AND_ASSIGN(TCPSocketWin); 183 DISALLOW_COPY_AND_ASSIGN(TCPSocketWin);
180 }; 184 };
181 185
182 } // namespace net 186 } // namespace net
183 187
184 #endif // NET_SOCKET_TCP_SOCKET_WIN_H_ 188 #endif // NET_SOCKET_TCP_SOCKET_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698