diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 18:07:34 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 18:07:34 +0000 |
commit | 57ddb39b9db7d242c7cf136381bed5650b2355c4 (patch) | |
tree | 0f6590abb8bb31c64a8a05ceed2ee542b1133b06 /jingle/notifier/communicator/ssl_socket_adapter.h | |
parent | a9d211835596b2eaa88b1f0a50348b773c852221 (diff) | |
download | chromium_src-57ddb39b9db7d242c7cf136381bed5650b2355c4.zip chromium_src-57ddb39b9db7d242c7cf136381bed5650b2355c4.tar.gz chromium_src-57ddb39b9db7d242c7cf136381bed5650b2355c4.tar.bz2 |
Fixed events handling in XmppSocketAdapter. Removed unnecessary warnings.
The problem was that SSLSocketAdapter::OnReadEvent() was calling AsyncSocketAdapter::OnReadEvent() only when there are no pending read requests, so the reader wasn't always receiving notification when new data is received on the socket, especially when data received is bigger than the pending read request.
BUG=none
TEST=xmpp connection succeeds 100% of the time, particularly on mac.
Review URL: http://codereview.chromium.org/2834024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51385 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle/notifier/communicator/ssl_socket_adapter.h')
-rw-r--r-- | jingle/notifier/communicator/ssl_socket_adapter.h | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/jingle/notifier/communicator/ssl_socket_adapter.h b/jingle/notifier/communicator/ssl_socket_adapter.h index a97cfaa..574e135 100644 --- a/jingle/notifier/communicator/ssl_socket_adapter.h +++ b/jingle/notifier/communicator/ssl_socket_adapter.h @@ -19,6 +19,8 @@ namespace notifier { class SSLSocketAdapter; +// TODO(sergeyu): Write unittests for this code! + // This class provides a wrapper to libjingle's talk_base::AsyncSocket that // implements Chromium's net::ClientSocket interface. It's used by // SSLSocketAdapter to enable Chromium's SSL implementation to work over @@ -53,11 +55,9 @@ class TransportSocket : public net::ClientSocket, public sigslot::has_slots<> { private: friend class SSLSocketAdapter; - void OnConnectEvent(talk_base::AsyncSocket * socket); - bool OnReadEvent(talk_base::AsyncSocket * socket); - bool OnWriteEvent(talk_base::AsyncSocket * socket); + void OnReadEvent(talk_base::AsyncSocket* socket); + void OnWriteEvent(talk_base::AsyncSocket* socket); - net::CompletionCallback* connect_callback_; net::CompletionCallback* read_callback_; net::CompletionCallback* write_callback_; @@ -97,21 +97,23 @@ class SSLSocketAdapter : public talk_base::SSLAdapter { private: friend class TransportSocket; - enum State { - STATE_NONE, - STATE_READ, - STATE_READ_COMPLETE, - STATE_WRITE, - STATE_WRITE_COMPLETE, - STATE_SSL_WAIT + enum SSLState { + SSLSTATE_NONE, + SSLSTATE_WAIT, + SSLSTATE_CONNECTED, + }; + + enum IOState { + IOSTATE_NONE, + IOSTATE_PENDING, + IOSTATE_COMPLETE, }; void OnConnected(int result); - void OnIO(int result); + void OnRead(int result); + void OnWrite(int result); - void OnReadEvent(talk_base::AsyncSocket * socket); - void OnWriteEvent(talk_base::AsyncSocket * socket); - void OnConnectEvent(talk_base::AsyncSocket * socket); + virtual void OnConnectEvent(talk_base::AsyncSocket* socket); int BeginSSL(); @@ -120,9 +122,11 @@ class SSLSocketAdapter : public talk_base::SSLAdapter { TransportSocket* transport_socket_; scoped_ptr<net::SSLClientSocket> ssl_socket_; net::CompletionCallbackImpl<SSLSocketAdapter> connected_callback_; - net::CompletionCallbackImpl<SSLSocketAdapter> io_callback_; - bool ssl_connected_; - State state_; + net::CompletionCallbackImpl<SSLSocketAdapter> read_callback_; + net::CompletionCallbackImpl<SSLSocketAdapter> write_callback_; + SSLState ssl_state_; + IOState read_state_; + IOState write_state_; scoped_refptr<net::IOBuffer> transport_buf_; int data_transferred_; |