shill: Convert code to use the newest version of libchrome.
The biggest change is a switch from using the deprecated
Task and CallbackN mechanisms to using the new Callback
mechanism.
Note: Original CL was https://gerrit.chromium.org/gerrit/16156.
This is logically another patch to that CL, but since the
latter was already merged, and is considered closed by
Gerrit, it's necessary to create a new CL.
BUG=chromium-os:15330
TEST=Build shill and run it on a zgb with a modem. Build and
run unit tests.
CQ-DEPEND=I37628863370323d30cac493764ea28f8ffd42637
Change-Id: I3ae78a3aa44ec167b79f2170d07650ece888254f
Reviewed-on: https://gerrit.chromium.org/gerrit/18030
Reviewed-by: Eric Shienbrood <ers@chromium.org>
Tested-by: Eric Shienbrood <ers@chromium.org>
Commit-Ready: Eric Shienbrood <ers@chromium.org>
diff --git a/async_connection.cc b/async_connection.cc
index 63530ec..e897b1c 100644
--- a/async_connection.cc
+++ b/async_connection.cc
@@ -1,9 +1,10 @@
-// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "shill/async_connection.h"
+#include <base/bind.h>
#include <errno.h>
#include <netinet/in.h>
@@ -13,6 +14,9 @@
#include "shill/ip_address.h"
#include "shill/sockets.h"
+using base::Bind;
+using base::Callback;
+using base::Unretained;
using std::string;
namespace shill {
@@ -20,14 +24,14 @@
AsyncConnection::AsyncConnection(const string &interface_name,
EventDispatcher *dispatcher,
Sockets *sockets,
- Callback2<bool, int>::Type *callback)
+ const Callback<void(bool, int)> &callback)
: interface_name_(interface_name),
dispatcher_(dispatcher),
sockets_(sockets),
callback_(callback),
fd_(-1),
connect_completion_callback_(
- NewCallback(this, &AsyncConnection::OnConnectCompletion)) { }
+ Bind(&AsyncConnection::OnConnectCompletion, Unretained(this))) { }
AsyncConnection::~AsyncConnection() {
Stop();
@@ -67,7 +71,7 @@
reinterpret_cast<struct sockaddr *>(&iaddr),
addrlen);
if (ret == 0) {
- callback_->Run(true, fd_); // Passes ownership
+ callback_.Run(true, fd_); // Passes ownership
fd_ = -1;
return true;
}
@@ -82,7 +86,7 @@
connect_completion_handler_.reset(
dispatcher_->CreateReadyHandler(fd_,
IOHandler::kModeOutput,
- connect_completion_callback_.get()));
+ connect_completion_callback_));
error_ = string();
return true;
@@ -102,9 +106,9 @@
if (sockets_->GetSocketError(fd_) != 0) {
error_ = sockets_->ErrorString();
PLOG(ERROR) << "Async GetSocketError returns failure";
- callback_->Run(false, -1);
+ callback_.Run(false, -1);
} else {
- callback_->Run(true, fd_); // Passes ownership
+ callback_.Run(true, fd_); // Passes ownership
fd_ = -1;
}
Stop();