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

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, 4 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);
akalin 2013/08/26 18:53:21 can you explain again why TCPSocket needs to have
yzshen1 2013/08/26 23:09:57 In this discussion thread https://groups.google.co
37 int Accept(scoped_ptr<TCPSocketLibevent>* socket,
38 IPEndPoint* address,
39 const CompletionCallback& callback);
40 int SetAddressReuse(bool allow);
41 void Close();
42
43 const BoundNetLog& net_log() const { return net_log_; }
44
45 // MessageLoopForIO::Watcher implementation.
46 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
47 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
48
49 private:
50 int AcceptInternal(scoped_ptr<TCPSocketLibevent>* socket,
51 IPEndPoint* address);
52
53 int socket_;
54
55 base::MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_;
56
57 scoped_ptr<TCPSocketLibevent>* accept_socket_;
58 IPEndPoint* accept_address_;
59 CompletionCallback accept_callback_;
60
61 BoundNetLog net_log_;
62
63 DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent);
64 };
65
66 } // namespace net
67
68 #endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698