summaryrefslogtreecommitdiffstats
path: root/net/socket/tcp_server_socket_libevent.h
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-18 23:03:32 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-18 23:03:32 +0000
commit3871252036dec25ea2dca4622be40264a25b61d3 (patch)
tree67d45091d78abb5234b286437567f217dcd275cf /net/socket/tcp_server_socket_libevent.h
parent2b4f812537173e2ab27a9f9b94de3b4da4a5d22e (diff)
downloadchromium_src-3871252036dec25ea2dca4622be40264a25b61d3.zip
chromium_src-3871252036dec25ea2dca4622be40264a25b61d3.tar.gz
chromium_src-3871252036dec25ea2dca4622be40264a25b61d3.tar.bz2
Added TCPServerSocket.
BUG=None TEST=Unittests Review URL: http://codereview.chromium.org/6820057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/tcp_server_socket_libevent.h')
-rw-r--r--net/socket/tcp_server_socket_libevent.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/net/socket/tcp_server_socket_libevent.h b/net/socket/tcp_server_socket_libevent.h
new file mode 100644
index 0000000..9d30953
--- /dev/null
+++ b/net/socket/tcp_server_socket_libevent.h
@@ -0,0 +1,53 @@
+// 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/scoped_ptr.h"
+#include "base/threading/non_thread_safe.h"
+#include "net/base/completion_callback.h"
+#include "net/base/net_log.h"
+#include "net/socket/server_socket.h"
+
+namespace net {
+
+class IPEndPoint;
+
+class TCPServerSocketLibevent : public ServerSocket,
+ public base::NonThreadSafe,
+ public MessageLoopForIO::Watcher {
+ public:
+ TCPServerSocketLibevent(net::NetLog* net_log,
+ const net::NetLog::Source& source);
+ ~TCPServerSocketLibevent();
+
+ // net::ServerSocket implementation.
+ virtual int Listen(const net::IPEndPoint& address, int backlog);
+ virtual int GetLocalAddress(IPEndPoint* address) const;
+ virtual int Accept(scoped_ptr<ClientSocket>* socket,
+ CompletionCallback* callback);
+
+ // MessageLoopForIO::Watcher implementation.
+ virtual void OnFileCanReadWithoutBlocking(int fd);
+ virtual void OnFileCanWriteWithoutBlocking(int fd);
+
+ private:
+ int AcceptInternal(scoped_ptr<ClientSocket>* socket);
+ void Close();
+
+ int socket_;
+
+ MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_;
+
+ scoped_ptr<ClientSocket>* accept_socket_;
+ CompletionCallback* accept_callback_;
+
+ BoundNetLog net_log_;
+};
+
+} // namespace net
+
+#endif // NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_