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

Unified Diff: net/base/listen_socket.cc

Issue 14068: Reverting 6911. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years 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 | « net/base/listen_socket.h ('k') | net/base/tcp_client_socket.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/listen_socket.cc
===================================================================
--- net/base/listen_socket.cc (revision 6915)
+++ net/base/listen_socket.cc (working copy)
@@ -12,6 +12,7 @@
#include <errno.h>
#include <sys/socket.h>
#include <arpa/inet.h>
+#include "base/message_loop.h"
#include "net/base/net_errors.h"
#include "third_party/libevent/event.h"
#endif
@@ -29,7 +30,12 @@
const int kReadBufSize = 200;
ListenSocket::ListenSocket(SOCKET s, ListenSocketDelegate *del)
+#if defined(OS_WIN)
: socket_(s),
+#elif defined(OS_POSIX)
+ : event_(new event),
+ socket_(s),
+#endif
socket_delegate_(del) {
#if defined(OS_WIN)
socket_event_ = WSACreateEvent();
@@ -171,7 +177,8 @@
#if defined(OS_WIN)
watcher_.StopWatching();
#elif defined(OS_POSIX)
- watcher_.StopWatchingFileDescriptor();
+ MessageLoopForIO::current()->UnwatchSocket(event_.get());
+ wait_state_ = NOT_WAITING;
#endif
}
@@ -180,9 +187,8 @@
WSAEventSelect(socket_, socket_event_, FD_ACCEPT | FD_CLOSE | FD_READ);
watcher_.StartWatching(socket_event_, this);
#elif defined(OS_POSIX)
- // Implicitly calls StartWatchingFileDescriptor().
- MessageLoopForIO::current()->WatchFileDescriptor(
- socket_, true, MessageLoopForIO::WATCH_READ, &watcher_, this);
+ MessageLoopForIO::current()->WatchSocket(
+ socket_, EV_READ|EV_PERSIST, event_.get(),this);
wait_state_ = state;
#endif
}
@@ -244,7 +250,7 @@
}
}
#elif defined(OS_POSIX)
-void ListenSocket::OnFileCanReadWithoutBlocking(int fd) {
+void ListenSocket::OnSocketReady(short flags) {
if (wait_state_ == WAITING_ACCEPT) {
Accept();
}
@@ -256,11 +262,4 @@
// TODO(erikkay): this seems to get hit multiple times after the close
}
}
-
-void ListenSocket::OnFileCanWriteWithoutBlocking(int fd) {
- // MessagePumpLibevent callback, we don't listen for write events
- // so we shouldn't ever reach here.
- NOTREACHED();
-}
-
#endif
« no previous file with comments | « net/base/listen_socket.h ('k') | net/base/tcp_client_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698