summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-04 18:38:04 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-04 18:38:04 +0000
commit3fa4bad7827a6c725e3e8868d63ddee0d4b67b2d (patch)
treed9d8eb5d9bbff19689b9b4243dd2ce846b638e9b /net
parent2a4e5fbb838517d03c760974ccc6a2ff8939dd08 (diff)
downloadchromium_src-3fa4bad7827a6c725e3e8868d63ddee0d4b67b2d.zip
chromium_src-3fa4bad7827a6c725e3e8868d63ddee0d4b67b2d.tar.gz
chromium_src-3fa4bad7827a6c725e3e8868d63ddee0d4b67b2d.tar.bz2
was originally reviewed by jar as part of revision 322, but i mistakenly didn't commit it along with that revision
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@328 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/tcp_client_socket.cc10
-rw-r--r--net/base/tcp_client_socket.h7
2 files changed, 9 insertions, 8 deletions
diff --git a/net/base/tcp_client_socket.cc b/net/base/tcp_client_socket.cc
index fad4f2f0..6f9e52b 100644
--- a/net/base/tcp_client_socket.cc
+++ b/net/base/tcp_client_socket.cc
@@ -106,7 +106,7 @@ int TCPClientSocket::Connect(CompletionCallback* callback) {
overlapped_.hEvent = WSACreateEvent();
WSAEventSelect(socket_, overlapped_.hEvent, FD_CONNECT);
- MessageLoop::current()->WatchObject(overlapped_.hEvent, this);
+ watcher_.StartWatching(overlapped_.hEvent, this);
wait_state_ = WAITING_CONNECT;
callback_ = callback;
return ERR_IO_PENDING;
@@ -122,7 +122,7 @@ void TCPClientSocket::Disconnect() {
return;
// Make sure the message loop is not watching this object anymore.
- MessageLoop::current()->WatchObject(overlapped_.hEvent, NULL);
+ watcher_.StopWatching();
// This cancels any pending IO.
closesocket(socket_);
@@ -163,7 +163,7 @@ int TCPClientSocket::Read(char* buf, int buf_len, CompletionCallback* callback)
if (rv == 0)
return static_cast<int>(num);
if (rv == SOCKET_ERROR && WSAGetLastError() == WSA_IO_PENDING) {
- MessageLoop::current()->WatchObject(overlapped_.hEvent, this);
+ watcher_.StartWatching(overlapped_.hEvent, this);
wait_state_ = WAITING_READ;
callback_ = callback;
return ERR_IO_PENDING;
@@ -184,7 +184,7 @@ int TCPClientSocket::Write(const char* buf, int buf_len, CompletionCallback* cal
if (rv == 0)
return static_cast<int>(num);
if (rv == SOCKET_ERROR && WSAGetLastError() == WSA_IO_PENDING) {
- MessageLoop::current()->WatchObject(overlapped_.hEvent, this);
+ watcher_.StartWatching(overlapped_.hEvent, this);
wait_state_ = WAITING_WRITE;
callback_ = callback;
return ERR_IO_PENDING;
@@ -265,8 +265,6 @@ void TCPClientSocket::DidCompleteIO() {
void TCPClientSocket::OnObjectSignaled(HANDLE object) {
DCHECK(object == overlapped_.hEvent);
- MessageLoop::current()->WatchObject(overlapped_.hEvent, NULL);
-
switch (wait_state_) {
case WAITING_CONNECT:
DidCompleteConnect();
diff --git a/net/base/tcp_client_socket.h b/net/base/tcp_client_socket.h
index 1ed37a7..e5c8ca9 100644
--- a/net/base/tcp_client_socket.h
+++ b/net/base/tcp_client_socket.h
@@ -32,13 +32,14 @@
#include <ws2tcpip.h>
-#include "base/message_loop.h"
+#include "base/object_watcher.h"
#include "net/base/address_list.h"
#include "net/base/client_socket.h"
namespace net {
-class TCPClientSocket : public ClientSocket, public MessageLoop::Watcher {
+class TCPClientSocket : public ClientSocket,
+ public base::ObjectWatcher::Delegate {
public:
// The IP address(es) and port number to connect to. The TCP socket will try
// each IP address in the list until it succeeds in establishing a
@@ -69,6 +70,8 @@ class TCPClientSocket : public ClientSocket, public MessageLoop::Watcher {
OVERLAPPED overlapped_;
WSABUF buffer_;
+ base::ObjectWatcher watcher_;
+
CompletionCallback* callback_;
// Stored outside of the context so we can both lazily construct the context