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/tcp_socket_win.h

Issue 22861033: Move server socket functionality from TCPServerSocket into TCPSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/tcp_socket_unittest.cc ('k') | net/socket/tcp_socket_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_SOCKET_TCP_SOCKET_WIN_H_
6 #define NET_SOCKET_TCP_SOCKET_WIN_H_
7
8 #include <winsock2.h>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/threading/non_thread_safe.h"
15 #include "base/win/object_watcher.h"
16 #include "net/base/address_family.h"
17 #include "net/base/completion_callback.h"
18 #include "net/base/net_export.h"
19 #include "net/base/net_log.h"
20
21 namespace net {
22
23 class IPEndPoint;
24
25 // TODO(yzshen): This class is incomplete. TCP client operations (Connect/Read/
26 // Write/etc.) will be added. And TCPClientSocket will be changed to be a
27 // wrapper around TCPSocket.
28 class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe),
29 public base::win::ObjectWatcher::Delegate {
30 public:
31 TCPSocketWin(NetLog* net_log, const NetLog::Source& source);
32 virtual ~TCPSocketWin();
33
34 int Create(AddressFamily family);
35 // Takes ownership of |socket|.
36 int Adopt(SOCKET socket);
37 // Returns a socket descriptor. The ownership is transferred to the caller.
38 SOCKET Release();
39 int Bind(const IPEndPoint& address);
40 int GetLocalAddress(IPEndPoint* address) const;
41 int Listen(int backlog);
42 int Accept(scoped_ptr<TCPSocketWin>* socket,
43 IPEndPoint* address,
44 const CompletionCallback& callback);
45 int SetDefaultOptionsForServer();
46 int SetExclusiveAddrUse();
47 void Close();
48
49 const BoundNetLog& net_log() const { return net_log_; }
50
51 // base::ObjectWatcher::Delegate implementation.
52 virtual void OnObjectSignaled(HANDLE object) OVERRIDE;
53
54 private:
55 int AcceptInternal(scoped_ptr<TCPSocketWin>* socket,
56 IPEndPoint* address);
57
58 SOCKET socket_;
59 HANDLE socket_event_;
60
61 base::win::ObjectWatcher accept_watcher_;
62
63 scoped_ptr<TCPSocketWin>* accept_socket_;
64 IPEndPoint* accept_address_;
65 CompletionCallback accept_callback_;
66
67 BoundNetLog net_log_;
68
69 DISALLOW_COPY_AND_ASSIGN(TCPSocketWin);
70 };
71
72 } // namespace net
73
74 #endif // NET_SOCKET_TCP_SOCKET_WIN_H_
OLDNEW
« no previous file with comments | « net/socket/tcp_socket_unittest.cc ('k') | net/socket/tcp_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698