diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-08 23:51:15 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-08 23:51:15 +0000 |
commit | 293f154b854a3507de8ed4116e8529f633060810 (patch) | |
tree | 63cc680a578707f0188e2615ebcd407906040166 /net/socket/ssl_client_socket_win.cc | |
parent | 4c6df432834aa4541044a0890f774b25e15e7746 (diff) | |
download | chromium_src-293f154b854a3507de8ed4116e8529f633060810.zip chromium_src-293f154b854a3507de8ed4116e8529f633060810.tar.gz chromium_src-293f154b854a3507de8ed4116e8529f633060810.tar.bz2 |
base::Bind: Convert Socket::Write.
BUG=none
TEST=none
R=csilv
Review URL: http://codereview.chromium.org/8831001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113699 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/ssl_client_socket_win.cc')
-rw-r--r-- | net/socket/ssl_client_socket_win.cc | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/net/socket/ssl_client_socket_win.cc b/net/socket/ssl_client_socket_win.cc index 30f599d..3c855fb 100644 --- a/net/socket/ssl_client_socket_win.cc +++ b/net/socket/ssl_client_socket_win.cc @@ -400,7 +400,7 @@ SSLClientSocketWin::SSLClientSocketWin(ClientSocketHandle* transport_socket, old_user_connect_callback_(NULL), old_user_read_callback_(NULL), user_read_buf_len_(0), - user_write_callback_(NULL), + old_user_write_callback_(NULL), user_write_buf_len_(0), next_state_(STATE_NONE), cert_verifier_(context.cert_verifier), @@ -869,7 +869,29 @@ int SSLClientSocketWin::Read(IOBuffer* buf, int buf_len, int SSLClientSocketWin::Write(IOBuffer* buf, int buf_len, OldCompletionCallback* callback) { DCHECK(completed_handshake()); - DCHECK(!user_write_callback_); + DCHECK(!old_user_write_callback_ && user_write_callback_.is_null()); + + DCHECK(!user_write_buf_); + user_write_buf_ = buf; + user_write_buf_len_ = buf_len; + + int rv = DoPayloadEncrypt(); + if (rv != OK) + return rv; + + rv = DoPayloadWrite(); + if (rv == ERR_IO_PENDING) { + old_user_write_callback_ = callback; + } else { + user_write_buf_ = NULL; + user_write_buf_len_ = 0; + } + return rv; +} +int SSLClientSocketWin::Write(IOBuffer* buf, int buf_len, + const CompletionCallback& callback) { + DCHECK(completed_handshake()); + DCHECK(!old_user_write_callback_ && user_write_callback_.is_null()); DCHECK(!user_write_buf_); user_write_buf_ = buf; @@ -964,12 +986,20 @@ void SSLClientSocketWin::OnWriteComplete(int result) { int rv = DoPayloadWriteComplete(result); if (rv != ERR_IO_PENDING) { - DCHECK(user_write_callback_); - OldCompletionCallback* c = user_write_callback_; - user_write_callback_ = NULL; - user_write_buf_ = NULL; - user_write_buf_len_ = 0; - c->Run(rv); + DCHECK(old_user_write_callback_ || !user_write_callback_.is_null()); + if (old_user_write_callback_) { + OldCompletionCallback* c = old_user_write_callback_; + old_user_write_callback_ = NULL; + user_write_buf_ = NULL; + user_write_buf_len_ = 0; + c->Run(rv); + } else { + CompletionCallback c = user_write_callback_; + user_write_callback_.Reset(); + user_write_buf_ = NULL; + user_write_buf_len_ = 0; + c.Run(rv); + } } } |