Roll ICU to r205936
[chromium-blink-merge.git] / net / socket / tcp_server_socket_win.h
blobfab8bf0cf2513a7081988a7fd47fcc29f62fa165
1 // Copyright (c) 2011 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.
5 #ifndef NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_
6 #define NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_
8 #include <winsock2.h>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h"
12 #include "base/win/object_watcher.h"
13 #include "base/threading/non_thread_safe.h"
14 #include "net/base/completion_callback.h"
15 #include "net/base/net_log.h"
16 #include "net/socket/server_socket.h"
18 namespace net {
20 class IPEndPoint;
22 class NET_EXPORT_PRIVATE TCPServerSocketWin
23 : public ServerSocket,
24 NON_EXPORTED_BASE(public base::NonThreadSafe),
25 public base::win::ObjectWatcher::Delegate {
26 public:
27 TCPServerSocketWin(net::NetLog* net_log,
28 const net::NetLog::Source& source);
29 ~TCPServerSocketWin();
31 // net::ServerSocket implementation.
32 virtual void AllowAddressReuse() OVERRIDE;
33 virtual int Listen(const net::IPEndPoint& address, int backlog) OVERRIDE;
34 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
35 virtual int Accept(scoped_ptr<StreamSocket>* socket,
36 const CompletionCallback& callback) OVERRIDE;
38 // base::ObjectWatcher::Delegate implementation.
39 virtual void OnObjectSignaled(HANDLE object);
41 private:
42 int SetSocketOptions();
43 int AcceptInternal(scoped_ptr<StreamSocket>* socket);
44 void Close();
46 SOCKET socket_;
47 HANDLE socket_event_;
49 base::win::ObjectWatcher accept_watcher_;
51 scoped_ptr<StreamSocket>* accept_socket_;
52 CompletionCallback accept_callback_;
54 bool reuse_address_;
56 BoundNetLog net_log_;
59 } // namespace net
61 #endif // NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_