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/message_loop.h" | |
9 #include "base/threading/non_thread_safe.h" | |
10 #include "net/base/completion_callback.h" | |
11 #include "net/socket/tcp_client_socket.h" | |
12 | |
13 namespace net { | |
14 | |
15 class IPEndPoint; | |
16 | |
17 class TCPServerSocketLibevent : public base::NonThreadSafe, | |
18 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.
| |
19 public: | |
20 TCPServerSocketLibevent(net::NetLog* net_log, | |
21 const net::NetLog::Source& source); | |
22 ~TCPServerSocketLibevent(); | |
23 | |
24 // Bind the socket and start listening. | |
25 int Bind(const net::IPEndPoint& address, int backlog); | |
26 | |
27 // Gets current address the socket is bound to. | |
28 int GetLocalAddress(IPEndPoint* address) const; | |
29 | |
30 // Accept connection. Callback is called when new connection is | |
31 // accepted. | |
32 int Accept(TCPClientSocket** socket, IPEndPoint* address, | |
33 CompletionCallback* callback); | |
34 private: | |
35 int AcceptInternal( | |
36 TCPClientSocket** socket, net::IPEndPoint* address); | |
37 | |
38 // MessageLoopForIO::Watcher implementation. | |
39 virtual void OnFileCanReadWithoutBlocking(int fd); | |
40 virtual void OnFileCanWriteWithoutBlocking(int fd); | |
41 | |
42 int socket_; | |
43 | |
44 MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_; | |
45 | |
46 TCPClientSocket** accept_socket_; | |
47 IPEndPoint* accept_address_; | |
48 CompletionCallback* accept_callback_; | |
49 | |
50 net::NetLog* net_log_; | |
51 net::NetLog::Source net_log_source_; | |
52 }; | |
53 | |
54 } // namespace net | |
55 | |
56 #endif // NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ | |
OLD | NEW |