| OLD | NEW |
| (Empty) |
| 1 // 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_LIBEVENT_H_ | |
| 6 #define NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/message_loop/message_loop.h" | |
| 10 #include "base/threading/non_thread_safe.h" | |
| 11 #include "net/base/completion_callback.h" | |
| 12 #include "net/base/net_log.h" | |
| 13 #include "net/socket/server_socket.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 class IPEndPoint; | |
| 18 | |
| 19 class NET_EXPORT_PRIVATE TCPServerSocketLibevent : | |
| 20 public ServerSocket, | |
| 21 public base::NonThreadSafe, | |
| 22 public base::MessageLoopForIO::Watcher { | |
| 23 public: | |
| 24 TCPServerSocketLibevent(net::NetLog* net_log, | |
| 25 const net::NetLog::Source& source); | |
| 26 virtual ~TCPServerSocketLibevent(); | |
| 27 | |
| 28 // net::ServerSocket implementation. | |
| 29 virtual int Listen(const net::IPEndPoint& address, int backlog) OVERRIDE; | |
| 30 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; | |
| 31 virtual int Accept(scoped_ptr<StreamSocket>* socket, | |
| 32 const CompletionCallback& callback) OVERRIDE; | |
| 33 | |
| 34 // MessageLoopForIO::Watcher implementation. | |
| 35 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | |
| 36 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | |
| 37 | |
| 38 private: | |
| 39 int SetSocketOptions(); | |
| 40 int AcceptInternal(scoped_ptr<StreamSocket>* socket); | |
| 41 void Close(); | |
| 42 | |
| 43 int socket_; | |
| 44 | |
| 45 base::MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_; | |
| 46 | |
| 47 scoped_ptr<StreamSocket>* accept_socket_; | |
| 48 CompletionCallback accept_callback_; | |
| 49 | |
| 50 BoundNetLog net_log_; | |
| 51 }; | |
| 52 | |
| 53 } // namespace net | |
| 54 | |
| 55 #endif // NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ | |
| OLD | NEW |