Chromium Code Reviews| Index: net/socket/tcp_server_socket_win.h |
| diff --git a/net/socket/tcp_server_socket_win.h b/net/socket/tcp_server_socket_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..22c39ed2cb13f961a3c26b80390f6b045187186e |
| --- /dev/null |
| +++ b/net/socket/tcp_server_socket_win.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_ |
| +#define NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_ |
| + |
| +#include <winsock2.h> |
| + |
| +#include "base/message_loop.h" |
| +#include "base/win/object_watcher.h" |
| +#include "base/threading/non_thread_safe.h" |
| +#include "net/base/completion_callback.h" |
| +#include "net/socket/tcp_client_socket.h" |
| + |
| +namespace net { |
| + |
| +class IPEndPoint; |
| + |
| +class TCPServerSocketWin : public base::NonThreadSafe, |
| + public base::win::ObjectWatcher::Delegate { |
| + public: |
| + TCPServerSocketWin(net::NetLog* net_log, |
| + const net::NetLog::Source& source); |
| + ~TCPServerSocketWin(); |
| + |
| + // Bind the socket and start listening. |
| + int Listen(const net::IPEndPoint& address, int backlog); |
| + |
| + // Gets current address the socket is bound to. |
| + int GetLocalAddress(IPEndPoint* address) const; |
| + |
| + // Accept connection. Callback is called when new connection is |
| + // accepted. |
| + int Accept(TCPClientSocket** socket, IPEndPoint* address, |
|
willchan no longer on Chromium
2011/04/13 16:08:51
One argument per line.
Sergey Ulanov
2011/04/13 21:20:19
Done.
|
| + CompletionCallback* callback); |
| + |
| + // base::ObjectWatcher::Delegate implementation. |
| + virtual void OnObjectSignaled(HANDLE object); |
| + |
| + private: |
| + int AcceptInternal(TCPClientSocket** socket, net::IPEndPoint* address); |
| + void Close(); |
| + |
| + SOCKET socket_; |
| + HANDLE socket_event_; |
| + |
| + base::win::ObjectWatcher accept_watcher_; |
| + |
| + TCPClientSocket** accept_socket_; |
| + IPEndPoint* accept_address_; |
| + CompletionCallback* accept_callback_; |
| + |
| + net::NetLog* net_log_; |
| + net::NetLog::Source net_log_source_; |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_SOCKET_TCP_SERVER_SOCKET_WIN_H_ |