Chromium Code Reviews| Index: net/socket/tcp_server_socket_libevent.h |
| diff --git a/net/socket/tcp_server_socket_libevent.h b/net/socket/tcp_server_socket_libevent.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8352035a38c63f42e6f232e1b368d9d1f0c8b406 |
| --- /dev/null |
| +++ b/net/socket/tcp_server_socket_libevent.h |
| @@ -0,0 +1,57 @@ |
| +// 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_LIBEVENT_H_ |
| +#define NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ |
| + |
| +#include "base/message_loop.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 TCPServerSocketLibevent : public base::NonThreadSafe, |
| + public MessageLoopForIO::Watcher { |
| + public: |
| + TCPServerSocketLibevent(net::NetLog* net_log, |
| + const net::NetLog::Source& source); |
| + ~TCPServerSocketLibevent(); |
| + |
| + // Bind the socket and start listening. |
|
willchan no longer on Chromium
2011/04/13 16:08:51
I guess it's implicit, but you might want to docum
Sergey Ulanov
2011/04/13 21:20:19
Done.
|
| + 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
http://dev.chromium.org/developers/coding-style#Co
Sergey Ulanov
2011/04/13 21:20:19
Done.
|
| + CompletionCallback* callback); |
| + |
| + // MessageLoopForIO::Watcher implementation. |
| + virtual void OnFileCanReadWithoutBlocking(int fd); |
| + virtual void OnFileCanWriteWithoutBlocking(int fd); |
| + |
| + private: |
| + int AcceptInternal(TCPClientSocket** socket, net::IPEndPoint* address); |
| + void Close(); |
| + |
| + int socket_; |
| + |
| + MessageLoopForIO::FileDescriptorWatcher accept_socket_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_LIBEVENT_H_ |