blob: 8da5fa1662150bfcd591e069b6d015e4b0f7c744 [file] [log] [blame]
[email protected]38712522011-04-18 23:03:321// 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.
4
5#ifndef NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_
6#define NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_
7
8#include <winsock2.h>
9
[email protected]e57a7162011-06-15 04:14:2310#include "base/memory/scoped_ptr.h"
[email protected]38712522011-04-18 23:03:3211#include "base/message_loop.h"
[email protected]38712522011-04-18 23:03:3212#include "base/win/object_watcher.h"
13#include "base/threading/non_thread_safe.h"
14#include "net/base/net_log.h"
15#include "net/socket/server_socket.h"
16
17namespace net {
18
19class IPEndPoint;
20
[email protected]172da1b2011-08-12 15:52:2621class NET_EXPORT_PRIVATE TCPServerSocketWin
[email protected]f8986012011-05-19 21:53:5822 : public ServerSocket,
23 NON_EXPORTED_BASE(public base::NonThreadSafe),
24 public base::win::ObjectWatcher::Delegate {
[email protected]38712522011-04-18 23:03:3225 public:
26 TCPServerSocketWin(net::NetLog* net_log,
27 const net::NetLog::Source& source);
28 ~TCPServerSocketWin();
29
30 // net::ServerSocket implementation.
31 virtual int Listen(const net::IPEndPoint& address, int backlog);
32 virtual int GetLocalAddress(IPEndPoint* address) const;
[email protected]3268023f2011-05-05 00:08:1033 virtual int Accept(scoped_ptr<StreamSocket>* socket,
[email protected]38712522011-04-18 23:03:3234 CompletionCallback* callback);
35
36 // base::ObjectWatcher::Delegate implementation.
37 virtual void OnObjectSignaled(HANDLE object);
38
39 private:
[email protected]3268023f2011-05-05 00:08:1040 int AcceptInternal(scoped_ptr<StreamSocket>* socket);
[email protected]38712522011-04-18 23:03:3241 void Close();
42
43 SOCKET socket_;
44 HANDLE socket_event_;
45
46 base::win::ObjectWatcher accept_watcher_;
47
[email protected]3268023f2011-05-05 00:08:1048 scoped_ptr<StreamSocket>* accept_socket_;
[email protected]38712522011-04-18 23:03:3249 CompletionCallback* accept_callback_;
50
51 BoundNetLog net_log_;
52};
53
54} // namespace net
55
56#endif // NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_