summaryrefslogtreecommitdiffstats
path: root/net/base/tcp_client_socket_win.h
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-12 00:13:46 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-12 00:13:46 +0000
commit7d0fade425ef78dda741b1b1a34094cc5948f8f7 (patch)
tree99f5f8e9fc6a4c23adcb6ac78ca69fd6cae26142 /net/base/tcp_client_socket_win.h
parenta5ca79bd123f0d20fea5c76d0bb36128bb925f3a (diff)
downloadchromium_src-7d0fade425ef78dda741b1b1a34094cc5948f8f7.zip
chromium_src-7d0fade425ef78dda741b1b1a34094cc5948f8f7.tar.gz
chromium_src-7d0fade425ef78dda741b1b1a34094cc5948f8f7.tar.bz2
Create a detachable core for the TCPClientSocketWin object
so that part of the socket can outlive the socket destruction. This is the second part of removing infinite waits from the IO loop. BUG=9258 TEST=none Review URL: http://codereview.chromium.org/113172 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/tcp_client_socket_win.h')
-rw-r--r--net/base/tcp_client_socket_win.h53
1 files changed, 7 insertions, 46 deletions
diff --git a/net/base/tcp_client_socket_win.h b/net/base/tcp_client_socket_win.h
index 0199bfc..87a5a83 100644
--- a/net/base/tcp_client_socket_win.h
+++ b/net/base/tcp_client_socket_win.h
@@ -36,36 +36,14 @@ class TCPClientSocketWin : public ClientSocket {
virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback);
private:
- class ReadDelegate : public base::ObjectWatcher::Delegate {
- public:
- explicit ReadDelegate(TCPClientSocketWin* tcp_socket)
- : tcp_socket_(tcp_socket) { }
- virtual ~ReadDelegate() { }
-
- // base::ObjectWatcher::Delegate methods:
- virtual void OnObjectSignaled(HANDLE object);
-
- private:
- TCPClientSocketWin* const tcp_socket_;
- };
-
- class WriteDelegate : public base::ObjectWatcher::Delegate {
- public:
- explicit WriteDelegate(TCPClientSocketWin* tcp_socket)
- : tcp_socket_(tcp_socket) { }
- virtual ~WriteDelegate() { }
-
- // base::ObjectWatcher::Delegate methods:
- virtual void OnObjectSignaled(HANDLE object);
-
- private:
- TCPClientSocketWin* const tcp_socket_;
- };
+ class Core;
int CreateSocket(const struct addrinfo* ai);
void DoReadCallback(int rv);
void DoWriteCallback(int rv);
void DidCompleteConnect();
+ void DidCompleteRead();
+ void DidCompleteWrite();
SOCKET socket_;
@@ -80,27 +58,10 @@ class TCPClientSocketWin : public ClientSocket {
bool waiting_read_;
bool waiting_write_;
- // The separate OVERLAPPED variables for asynchronous operation.
- // |read_overlapped_| is used for both Connect() and Read().
- // |write_overlapped_| is only used for Write();
- OVERLAPPED read_overlapped_;
- OVERLAPPED write_overlapped_;
-
- // The buffers used in Read() and Write().
- WSABUF read_buffer_;
- WSABUF write_buffer_;
- scoped_refptr<IOBuffer> read_iobuffer_;
- scoped_refptr<IOBuffer> write_iobuffer_;
-
- // |reader_| handles the signals from |read_watcher_|.
- ReadDelegate reader_;
- // |writer_| handles the signals from |write_watcher_|.
- WriteDelegate writer_;
-
- // |read_watcher_| watches for events from Connect() and Read().
- base::ObjectWatcher read_watcher_;
- // |write_watcher_| watches for events from Write();
- base::ObjectWatcher write_watcher_;
+ // The core of the socket that can live longer than the socket itself. We pass
+ // resources to the Windows async IO functions and we have to make sure that
+ // they are not destroyed while the OS still references them.
+ scoped_refptr<Core> core_;
// External callback; called when connect or read is complete.
CompletionCallback* read_callback_;