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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: net/socket/tcp_socket_libevent.h
diff --git a/net/socket/tcp_socket_libevent.h b/net/socket/tcp_socket_libevent.h
new file mode 100644
index 0000000000000000000000000000000000000000..2267a1960d82b83bbe4748571736f680dd9eebc8
--- /dev/null
+++ b/net/socket/tcp_socket_libevent.h
@@ -0,0 +1,68 @@
+// Copyright (c) 2013 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_SOCKET_LIBEVENT_H_
+#define NET_SOCKET_TCP_SOCKET_LIBEVENT_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "base/threading/non_thread_safe.h"
+#include "net/base/address_family.h"
+#include "net/base/completion_callback.h"
+#include "net/base/net_export.h"
+#include "net/base/net_log.h"
+
+namespace net {
+
+class IPEndPoint;
+
+class NET_EXPORT TCPSocketLibevent : public base::NonThreadSafe,
+ public base::MessageLoopForIO::Watcher {
+ public:
+ TCPSocketLibevent(NetLog* net_log, const NetLog::Source& source);
+ virtual ~TCPSocketLibevent();
+
+ int Create(AddressFamily family);
+ // Takes ownership of |socket|.
+ int Adopt(int socket);
+ // Returns a socket file descriptor. The ownership is transferred to the
+ // caller.
+ int Release();
+ int Bind(const IPEndPoint& address);
+ int GetLocalAddress(IPEndPoint* address) const;
+ 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
+ int Accept(scoped_ptr<TCPSocketLibevent>* socket,
+ IPEndPoint* address,
+ const CompletionCallback& callback);
+ int SetAddressReuse(bool allow);
+ void Close();
+
+ const BoundNetLog& net_log() const { return net_log_; }
+
+ // MessageLoopForIO::Watcher implementation.
+ virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
+ virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
+
+ private:
+ int AcceptInternal(scoped_ptr<TCPSocketLibevent>* socket,
+ IPEndPoint* address);
+
+ int socket_;
+
+ base::MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_;
+
+ scoped_ptr<TCPSocketLibevent>* accept_socket_;
+ IPEndPoint* accept_address_;
+ CompletionCallback accept_callback_;
+
+ BoundNetLog net_log_;
+
+ DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent);
+};
+
+} // namespace net
+
+#endif // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_

Powered by Google App Engine
This is Rietveld 408576698