summaryrefslogtreecommitdiffstats
path: root/net/curvecp/client_packetizer.cc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-06 23:33:24 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-06 23:33:24 +0000
commitdbf036fcb743cfdcd5be421364c8b89b10ee3f55 (patch)
tree034c3028c8b523d2bb6c2703416b26a81bc31663 /net/curvecp/client_packetizer.cc
parentad24b1827fe58c4a22c0cddb5791a95f2ab1b21b (diff)
downloadchromium_src-dbf036fcb743cfdcd5be421364c8b89b10ee3f55.zip
chromium_src-dbf036fcb743cfdcd5be421364c8b89b10ee3f55.tar.gz
chromium_src-dbf036fcb743cfdcd5be421364c8b89b10ee3f55.tar.bz2
base::Bind: Convert StreamSocket::Connect.
BUG=none TEST=none R=csilv Review URL: http://codereview.chromium.org/8801004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/curvecp/client_packetizer.cc')
-rw-r--r--net/curvecp/client_packetizer.cc36
1 files changed, 29 insertions, 7 deletions
diff --git a/net/curvecp/client_packetizer.cc b/net/curvecp/client_packetizer.cc
index 72bf4a0..77ddfda 100644
--- a/net/curvecp/client_packetizer.cc
+++ b/net/curvecp/client_packetizer.cc
@@ -33,7 +33,7 @@ ClientPacketizer::ClientPacketizer()
: Packetizer(),
next_state_(NONE),
listener_(NULL),
- user_callback_(NULL),
+ old_user_callback_(NULL),
current_address_(NULL),
hello_attempts_(0),
initiate_sent_(false),
@@ -52,7 +52,23 @@ ClientPacketizer::~ClientPacketizer() {
int ClientPacketizer::Connect(const AddressList& server,
Packetizer::Listener* listener,
OldCompletionCallback* callback) {
- DCHECK(!user_callback_);
+ DCHECK(!old_user_callback_);
+ DCHECK(!socket_.get());
+ DCHECK(!listener_);
+
+ listener_ = listener;
+
+ addresses_ = server;
+
+ old_user_callback_ = callback;
+ next_state_ = LOOKUP_COOKIE;
+
+ return DoLoop(OK);
+}
+int ClientPacketizer::Connect(const AddressList& server,
+ Packetizer::Listener* listener,
+ const net::CompletionCallback& callback) {
+ DCHECK(user_callback_.is_null());
DCHECK(!socket_.get());
DCHECK(!listener_);
@@ -279,11 +295,17 @@ int ClientPacketizer::DoConnected(int rv) {
void ClientPacketizer::DoCallback(int result) {
DCHECK_NE(result, ERR_IO_PENDING);
- DCHECK(user_callback_);
-
- OldCompletionCallback* callback = user_callback_;
- user_callback_ = NULL;
- callback->Run(result);
+ DCHECK(old_user_callback_ || !user_callback_.is_null());
+
+ if (old_user_callback_) {
+ OldCompletionCallback* callback = old_user_callback_;
+ old_user_callback_ = NULL;
+ callback->Run(result);
+ } else {
+ CompletionCallback callback = user_callback_;
+ user_callback_.Reset();
+ callback.Run(result);
+ }
}
int ClientPacketizer::ConnectNextAddress() {