Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: net/socket/tcp_socket_libevent.h

Issue 22861033: Move server socket functionality from TCPServerSocket into TCPSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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_SOCKET_LIBEVENT_H_
6 #define NET_SOCKET_TCP_SOCKET_LIBEVENT_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "net/base/address_family.h"
14 #include "net/base/completion_callback.h"
15 #include "net/base/net_export.h"
16 #include "net/base/net_log.h"
17
18 namespace net {
19
20 class IPEndPoint;
21
22 class NET_EXPORT TCPSocketLibevent : public base::NonThreadSafe,
23 public base::MessageLoopForIO::Watcher {
24 public:
25 TCPSocketLibevent(NetLog* net_log, const NetLog::Source& source);
26 virtual ~TCPSocketLibevent();
27
28 int Create(AddressFamily family);
29 // Takes ownership of |socket|.
30 int Adopt(int socket);
31 // Returns a socket file descriptor. The ownership is transferred to the
32 // caller.
33 int Release();
34 int Bind(const IPEndPoint& address);
35 int GetLocalAddress(IPEndPoint* address) const;
36 int Listen(int backlog);
37 int Accept(scoped_ptr<TCPSocketLibevent>* socket,
38 IPEndPoint* address,
39 const CompletionCallback& callback);
40 int SetDefaultOptionsForServer();
41 int SetAddressReuse(bool allow);
42 void Close();
wtc 2013/08/30 18:45:49 You should add a comment to point out this class i
yzshen1 2013/08/30 18:59:47 Done. Thanks! On 2013/08/30 18:45:49, wtc wrote:
43
44 const BoundNetLog& net_log() const { return net_log_; }
45
46 // MessageLoopForIO::Watcher implementation.
47 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
48 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
49
50 private:
51 int AcceptInternal(scoped_ptr<TCPSocketLibevent>* socket,
52 IPEndPoint* address);
53
54 int socket_;
55
56 base::MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_;
57
58 scoped_ptr<TCPSocketLibevent>* accept_socket_;
59 IPEndPoint* accept_address_;
60 CompletionCallback accept_callback_;
61
62 BoundNetLog net_log_;
63
64 DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent);
65 };
66
67 } // namespace net
68
69 #endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698