diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-07 02:03:33 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-07 02:03:33 +0000 |
commit | 3f55aa10587b3eaa629d7e95de87998b399fe3e2 (patch) | |
tree | 0f407a7e7fc837bed337a9a5af787edbd9473ef6 /net/socket/ssl_server_socket_nss.cc | |
parent | b456003a580041d83e7f5a998c15f62ce380560f (diff) | |
download | chromium_src-3f55aa10587b3eaa629d7e95de87998b399fe3e2.zip chromium_src-3f55aa10587b3eaa629d7e95de87998b399fe3e2.tar.gz chromium_src-3f55aa10587b3eaa629d7e95de87998b399fe3e2.tar.bz2 |
base::Bind: Convert Socket::Read.
BUG=none
TEST=none
R=csilv
Review URL: http://codereview.chromium.org/8801005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113326 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/ssl_server_socket_nss.cc')
-rw-r--r-- | net/socket/ssl_server_socket_nss.cc | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/net/socket/ssl_server_socket_nss.cc b/net/socket/ssl_server_socket_nss.cc index 8ead679..0785dd7d 100644 --- a/net/socket/ssl_server_socket_nss.cc +++ b/net/socket/ssl_server_socket_nss.cc @@ -65,7 +65,7 @@ SSLServerSocketNSS::SSLServerSocketNSS( transport_send_busy_(false), transport_recv_busy_(false), user_handshake_callback_(NULL), - user_read_callback_(NULL), + old_user_read_callback_(NULL), user_write_callback_(NULL), nss_fd_(NULL), nss_bufs_(NULL), @@ -154,7 +154,29 @@ int SSLServerSocketNSS::Connect(const CompletionCallback& callback) { int SSLServerSocketNSS::Read(IOBuffer* buf, int buf_len, OldCompletionCallback* callback) { - DCHECK(!user_read_callback_); + DCHECK(!old_user_read_callback_ && user_read_callback_.is_null()); + DCHECK(!user_handshake_callback_); + DCHECK(!user_read_buf_); + DCHECK(nss_bufs_); + + user_read_buf_ = buf; + user_read_buf_len_ = buf_len; + + DCHECK(completed_handshake_); + + int rv = DoReadLoop(OK); + + if (rv == ERR_IO_PENDING) { + old_user_read_callback_ = callback; + } else { + user_read_buf_ = NULL; + user_read_buf_len_ = 0; + } + return rv; +} +int SSLServerSocketNSS::Read(IOBuffer* buf, int buf_len, + const CompletionCallback& callback) { + DCHECK(!old_user_read_callback_ && user_read_callback_.is_null()); DCHECK(!user_handshake_callback_); DCHECK(!user_read_buf_); DCHECK(nss_bufs_); @@ -717,15 +739,23 @@ void SSLServerSocketNSS::DoHandshakeCallback(int rv) { void SSLServerSocketNSS::DoReadCallback(int rv) { DCHECK(rv != ERR_IO_PENDING); - DCHECK(user_read_callback_); + DCHECK(old_user_read_callback_ || !user_read_callback_.is_null()); // Since Run may result in Read being called, clear |user_read_callback_| // up front. - OldCompletionCallback* c = user_read_callback_; - user_read_callback_ = NULL; - user_read_buf_ = NULL; - user_read_buf_len_ = 0; - c->Run(rv); + if (old_user_read_callback_) { + OldCompletionCallback* c = old_user_read_callback_; + old_user_read_callback_ = NULL; + user_read_buf_ = NULL; + user_read_buf_len_ = 0; + c->Run(rv); + } else { + CompletionCallback c = user_read_callback_; + user_read_callback_.Reset(); + user_read_buf_ = NULL; + user_read_buf_len_ = 0; + c.Run(rv); + } } void SSLServerSocketNSS::DoWriteCallback(int rv) { |