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

Unified Diff: net/base/listen_socket.h

Issue 6577: Porting of listen_socket, telnet_server to linux (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 2 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
« no previous file with comments | « no previous file | net/base/listen_socket.cc » ('j') | net/base/listen_socket_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/listen_socket.h
===================================================================
--- net/base/listen_socket.h (revision 3911)
+++ net/base/listen_socket.h (working copy)
@@ -11,15 +11,33 @@
#ifndef NET_BASE_SOCKET_H_
#define NET_BASE_SOCKET_H_
+#if defined(OS_WIN)
+#include <winsock2.h>
+#include "base/object_watcher.h"
+#elif defined(OS_POSIX)
+#include "base/message_loop.h"
+#include "net/base/net_util.h"
+#include "net/base/net_errors.h"
+#include "third_party/libevent/event.h"
+#include "base/message_pump_libevent.h"
+#endif
+
#include "base/basictypes.h"
-#include "base/object_watcher.h"
#include "base/ref_counted.h"
-#include <winsock2.h>
+#if defined(OS_POSIX)
+struct event; // From libevent
+#define SOCKET int
+#endif
// Implements a raw socket interface
class ListenSocket : public base::RefCountedThreadSafe<ListenSocket>,
- public base::ObjectWatcher::Delegate {
+#if defined(OS_WIN)
+ public base::ObjectWatcher::Delegate
+#elif defined(OS_POSIX)
+ public base::MessagePumpLibevent::Watcher
+#endif
+{
public:
// TODO(erikkay): this delegate should really be split into two parts
// to split up the listener from the connected socket. Perhaps this class
@@ -52,19 +70,38 @@
virtual void SendInternal(const char* bytes, int len);
- // ObjectWatcher delegate
- virtual void OnObjectSignaled(HANDLE object);
-
virtual void Listen();
virtual void Accept();
virtual void Read();
virtual void Close();
+ virtual void CloseSocket(SOCKET s);
- SOCKET socket_;
+ enum WaitState {
+ NOT_WAITING = 0,
+ WAITING_ACCEPT = 1,
+ WAITING_READ = 3,
+ WAITING_CLOSE = 4
+ };
+ // Pass any value in case of Windows, because in Windows
+ // we are not using state.
+ void WatchSocket(WaitState state);
+ void UnwatchSocket();
+
+#if defined(OS_WIN)
+ // ObjectWatcher delegate
+ virtual void OnObjectSignaled(HANDLE object);
+ base::ObjectWatcher watcher_;
HANDLE socket_event_;
+#elif defined(OS_POSIX)
+ WaitState wait_state_;
+ // The socket's libevent wrapper
+ scoped_ptr<event> event_;
+ // Called by MessagePumpLibevent when the socket is ready to do I/O
+ void OnSocketReady(short flags);
+#endif
+
+ SOCKET socket_;
ListenSocketDelegate *socket_delegate_;
-
- base::ObjectWatcher watcher_;
private:
DISALLOW_EVIL_CONSTRUCTORS(ListenSocket);
« no previous file with comments | « no previous file | net/base/listen_socket.cc » ('j') | net/base/listen_socket_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698