blob: a7ab78cd4e9dc51c7dc399675722d2189f31a6fe [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"
[email protected]df7a30d2011-12-03 04:16:5014#include "net/base/completion_callback.h"
[email protected]38712522011-04-18 23:03:3215#include "net/base/net_log.h"
16#include "net/socket/server_socket.h"
17
18namespace net {
19
20class IPEndPoint;
21
[email protected]172da1b2011-08-12 15:52:2622class NET_EXPORT_PRIVATE TCPServerSocketWin
[email protected]f8986012011-05-19 21:53:5823 : public ServerSocket,
24 NON_EXPORTED_BASE(public base::NonThreadSafe),
25 public base::win::ObjectWatcher::Delegate {
[email protected]38712522011-04-18 23:03:3226 public:
27 TCPServerSocketWin(net::NetLog* net_log,
28 const net::NetLog::Source& source);
29 ~TCPServerSocketWin();
30
31 // net::ServerSocket implementation.
32 virtual int Listen(const net::IPEndPoint& address, int backlog);
33 virtual int GetLocalAddress(IPEndPoint* address) const;
[email protected]3268023f2011-05-05 00:08:1034 virtual int Accept(scoped_ptr<StreamSocket>* socket,
[email protected]df7a30d2011-12-03 04:16:5035 const CompletionCallback& callback);
[email protected]38712522011-04-18 23:03:3236
37 // base::ObjectWatcher::Delegate implementation.
38 virtual void OnObjectSignaled(HANDLE object);
39
40 private:
[email protected]3268023f2011-05-05 00:08:1041 int AcceptInternal(scoped_ptr<StreamSocket>* socket);
[email protected]38712522011-04-18 23:03:3242 void Close();
43
44 SOCKET socket_;
45 HANDLE socket_event_;
46
47 base::win::ObjectWatcher accept_watcher_;
48
[email protected]3268023f2011-05-05 00:08:1049 scoped_ptr<StreamSocket>* accept_socket_;
[email protected]df7a30d2011-12-03 04:16:5050 CompletionCallback accept_callback_;
[email protected]38712522011-04-18 23:03:3251
52 BoundNetLog net_log_;
53};
54
55} // namespace net
56
57#endif // NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_