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..334efb36db78281bf6e6d79789bd987e00ca809c |
--- /dev/null |
+++ b/net/socket/tcp_server_socket_libevent.h |
@@ -0,0 +1,56 @@ |
+// 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, |
+ private MessageLoopForIO::Watcher { |
willchan no longer on Chromium
2011/04/12 16:45:00
Don't use private inheritance please (http://www.p
Sergey Ulanov
2011/04/12 19:20:46
Done.
|
+ public: |
+ TCPServerSocketLibevent(net::NetLog* net_log, |
+ const net::NetLog::Source& source); |
+ ~TCPServerSocketLibevent(); |
+ |
+ // Bind the socket and start listening. |
+ int Bind(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, |
+ CompletionCallback* callback); |
+ private: |
+ int AcceptInternal( |
+ TCPClientSocket** socket, net::IPEndPoint* address); |
+ |
+ // MessageLoopForIO::Watcher implementation. |
+ virtual void OnFileCanReadWithoutBlocking(int fd); |
+ virtual void OnFileCanWriteWithoutBlocking(int fd); |
+ |
+ 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_ |