From 57ddb39b9db7d242c7cf136381bed5650b2355c4 Mon Sep 17 00:00:00 2001 From: "sergeyu@chromium.org" Date: Thu, 1 Jul 2010 18:07:34 +0000 Subject: 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 --- jingle/notifier/communicator/ssl_socket_adapter.h | 40 +++++++++++++---------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'jingle/notifier/communicator/ssl_socket_adapter.h') 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 ssl_socket_; net::CompletionCallbackImpl connected_callback_; - net::CompletionCallbackImpl io_callback_; - bool ssl_connected_; - State state_; + net::CompletionCallbackImpl read_callback_; + net::CompletionCallbackImpl write_callback_; + SSLState ssl_state_; + IOState read_state_; + IOState write_state_; scoped_refptr transport_buf_; int data_transferred_; -- cgit v1.1