summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/dbus_method_call_status.h4
-rw-r--r--chromeos/dbus/mock_shill_device_client.h5
-rw-r--r--chromeos/dbus/mock_shill_manager_client.h30
-rw-r--r--chromeos/dbus/mock_shill_profile_client.h19
-rw-r--r--chromeos/dbus/mock_shill_service_client.h25
-rw-r--r--chromeos/dbus/shill_client_helper.cc44
-rw-r--r--chromeos/dbus/shill_client_helper.h12
-rw-r--r--chromeos/dbus/shill_client_unittest_base.cc20
-rw-r--r--chromeos/dbus/shill_client_unittest_base.h10
-rw-r--r--chromeos/dbus/shill_device_client.cc19
-rw-r--r--chromeos/dbus/shill_device_client.h3
-rw-r--r--chromeos/dbus/shill_device_client_unittest.cc17
-rw-r--r--chromeos/dbus/shill_manager_client.cc81
-rw-r--r--chromeos/dbus/shill_manager_client.h19
-rw-r--r--chromeos/dbus/shill_manager_client_unittest.cc50
-rw-r--r--chromeos/dbus/shill_profile_client.cc52
-rw-r--r--chromeos/dbus/shill_profile_client.h16
-rw-r--r--chromeos/dbus/shill_profile_client_unittest.cc21
-rw-r--r--chromeos/dbus/shill_service_client.cc67
-rw-r--r--chromeos/dbus/shill_service_client.h15
-rw-r--r--chromeos/dbus/shill_service_client_unittest.cc40
21 files changed, 414 insertions, 155 deletions
diff --git a/chromeos/dbus/dbus_method_call_status.h b/chromeos/dbus/dbus_method_call_status.h
index a45611e..29fa84f 100644
--- a/chromeos/dbus/dbus_method_call_status.h
+++ b/chromeos/dbus/dbus_method_call_status.h
@@ -39,6 +39,10 @@ typedef base::Callback<void(
DBusMethodCallStatus call_status,
const dbus::ObjectPath& result)> ObjectPathDBusMethodCallback;
+// A callback to handle responses of methods returning a ObjectPath value that
+// doens't get call status.
+typedef base::Callback<void(const dbus::ObjectPath& result)> ObjectPathCallback;
+
} // namespace chromeos
#endif // CHROMEOS_DBUS_DBUS_METHOD_CALL_STATUS_H_
diff --git a/chromeos/dbus/mock_shill_device_client.h b/chromeos/dbus/mock_shill_device_client.h
index 1f0533a..fa0372c 100644
--- a/chromeos/dbus/mock_shill_device_client.h
+++ b/chromeos/dbus/mock_shill_device_client.h
@@ -30,10 +30,11 @@ class MockShillDeviceClient : public ShillDeviceClient {
base::DictionaryValue*(const dbus::ObjectPath& device_path));
MOCK_METHOD2(ProposeScan, void(const dbus::ObjectPath& device_path,
const VoidDBusMethodCallback& callback));
- MOCK_METHOD4(SetProperty, void(const dbus::ObjectPath& device_path,
+ MOCK_METHOD5(SetProperty, void(const dbus::ObjectPath& device_path,
const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback));
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
MOCK_METHOD3(ClearProperty, void(const dbus::ObjectPath& device_path,
const std::string& name,
const VoidDBusMethodCallback& callback));
diff --git a/chromeos/dbus/mock_shill_manager_client.h b/chromeos/dbus/mock_shill_manager_client.h
index e8b4c8b..b022520 100644
--- a/chromeos/dbus/mock_shill_manager_client.h
+++ b/chromeos/dbus/mock_shill_manager_client.h
@@ -23,19 +23,25 @@ class MockShillManagerClient : public ShillManagerClient {
void(ShillPropertyChangedObserver* observer));
MOCK_METHOD1(GetProperties, void(const DictionaryValueCallback& callback));
MOCK_METHOD0(CallGetPropertiesAndBlock, base::DictionaryValue*());
- MOCK_METHOD3(SetProperty, void(const std::string& name,
+ MOCK_METHOD4(SetProperty, void(const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD2(RequestScan, void(const std::string& type,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD2(EnableTechnology, void(const std::string& type,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD2(DisableTechnology, void(const std::string& type,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD2(ConfigureService, void(const base::DictionaryValue& properties,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD2(GetService, void(const base::DictionaryValue& properties,
- const ObjectPathDBusMethodCallback& callback));
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
+ MOCK_METHOD3(RequestScan, void(const std::string& type,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
+ MOCK_METHOD3(EnableTechnology, void(const std::string& type,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
+ MOCK_METHOD3(DisableTechnology, void(const std::string& type,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
+ MOCK_METHOD3(ConfigureService, void(const base::DictionaryValue& properties,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
+ MOCK_METHOD3(GetService, void(const base::DictionaryValue& properties,
+ const ObjectPathCallback& callback,
+ const ErrorCallback& error_callback));
};
} // namespace chromeos
diff --git a/chromeos/dbus/mock_shill_profile_client.h b/chromeos/dbus/mock_shill_profile_client.h
index 0ce9221..078bb60 100644
--- a/chromeos/dbus/mock_shill_profile_client.h
+++ b/chromeos/dbus/mock_shill_profile_client.h
@@ -26,14 +26,19 @@ class MockShillProfileClient : public ShillProfileClient {
MOCK_METHOD2(RemovePropertyChangedObserver,
void(const dbus::ObjectPath& profile_path,
ShillPropertyChangedObserver* observer));
- MOCK_METHOD2(GetProperties, void(const dbus::ObjectPath& profile_path,
- const DictionaryValueCallback& callback));
- MOCK_METHOD3(GetEntry, void(const dbus::ObjectPath& profile_path,
- const std::string& entry_path,
- const DictionaryValueCallback& callback));
- MOCK_METHOD3(DeleteEntry, void(const dbus::ObjectPath& profile_path,
+ MOCK_METHOD3(GetProperties, void(
+ const dbus::ObjectPath& profile_path,
+ const DictionaryValueCallbackWithoutStatus& callback,
+ const ErrorCallback& error_callback));
+ MOCK_METHOD4(GetEntry, void(
+ const dbus::ObjectPath& profile_path,
+ const std::string& entry_path,
+ const DictionaryValueCallbackWithoutStatus& callback,
+ const ErrorCallback& error_callback));
+ MOCK_METHOD4(DeleteEntry, void(const dbus::ObjectPath& profile_path,
const std::string& entry_path,
- const VoidDBusMethodCallback& callback));
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
};
} // namespace chromeos
diff --git a/chromeos/dbus/mock_shill_service_client.h b/chromeos/dbus/mock_shill_service_client.h
index d8dfb0b..12d14bb 100644
--- a/chromeos/dbus/mock_shill_service_client.h
+++ b/chromeos/dbus/mock_shill_service_client.h
@@ -26,24 +26,29 @@ class MockShillServiceClient : public ShillServiceClient {
ShillPropertyChangedObserver* observer));
MOCK_METHOD2(GetProperties, void(const dbus::ObjectPath& service_path,
const DictionaryValueCallback& callback));
- MOCK_METHOD4(SetProperty, void(const dbus::ObjectPath& service_path,
+ MOCK_METHOD5(SetProperty, void(const dbus::ObjectPath& service_path,
const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD3(ClearProperty, void(const dbus::ObjectPath& service_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
+ MOCK_METHOD4(ClearProperty, void(const dbus::ObjectPath& service_path,
const std::string& name,
- const VoidDBusMethodCallback& callback));
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
MOCK_METHOD3(Connect, void(const dbus::ObjectPath& service_path,
const base::Closure& callback,
const ErrorCallback& error_callback));
- MOCK_METHOD2(Disconnect, void(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD2(Remove, void(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback));
- MOCK_METHOD3(ActivateCellularModem,
+ MOCK_METHOD3(Disconnect, void(const dbus::ObjectPath& service_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
+ MOCK_METHOD3(Remove, void(const dbus::ObjectPath& service_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
+ MOCK_METHOD4(ActivateCellularModem,
void(const dbus::ObjectPath& service_path,
const std::string& carrier,
- const VoidDBusMethodCallback& callback));
+ const base::Closure& callback,
+ const ErrorCallback& error_callback));
MOCK_METHOD2(CallActivateCellularModemAndBlock,
bool(const dbus::ObjectPath& service_path,
const std::string& carrier));
diff --git a/chromeos/dbus/shill_client_helper.cc b/chromeos/dbus/shill_client_helper.cc
index 7bc7ef0..f6d0fdc 100644
--- a/chromeos/dbus/shill_client_helper.cc
+++ b/chromeos/dbus/shill_client_helper.cc
@@ -13,6 +13,13 @@
namespace chromeos {
+namespace {
+
+const char kInvalidResponseErrorName[] = ""; // No error name.
+const char kInvalidResponseErrorMessage[] = "Invalid response.";
+
+} // namespace
+
ShillClientHelper::ShillClientHelper(dbus::Bus* bus,
dbus::ObjectProxy* proxy)
: blocking_method_caller_(bus, proxy),
@@ -63,6 +70,22 @@ void ShillClientHelper::CallObjectPathMethod(
callback));
}
+void ShillClientHelper::CallObjectPathMethodWithErrorCallback(
+ dbus::MethodCall* method_call,
+ const ObjectPathCallback& callback,
+ const ErrorCallback& error_callback) {
+ proxy_->CallMethodWithErrorCallback(
+ method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&ShillClientHelper::OnObjectPathMethodWithoutStatus,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback,
+ error_callback),
+ base::Bind(&ShillClientHelper::OnError,
+ weak_ptr_factory_.GetWeakPtr(),
+ error_callback));
+}
+
void ShillClientHelper::CallDictionaryValueMethod(
dbus::MethodCall* method_call,
const DictionaryValueCallback& callback) {
@@ -233,6 +256,23 @@ void ShillClientHelper::OnObjectPathMethod(
callback.Run(DBUS_METHOD_CALL_SUCCESS, result);
}
+void ShillClientHelper::OnObjectPathMethodWithoutStatus(
+ const ObjectPathCallback& callback,
+ const ErrorCallback& error_callback,
+ dbus::Response* response) {
+ if (!response) {
+ error_callback.Run(kInvalidResponseErrorName, kInvalidResponseErrorMessage);
+ return;
+ }
+ dbus::MessageReader reader(response);
+ dbus::ObjectPath result;
+ if (!reader.PopObjectPath(&result)) {
+ error_callback.Run(kInvalidResponseErrorName, kInvalidResponseErrorMessage);
+ return;
+ }
+ callback.Run(result);
+}
+
void ShillClientHelper::OnDictionaryValueMethod(
const DictionaryValueCallback& callback,
dbus::Response* response) {
@@ -266,9 +306,7 @@ void ShillClientHelper::OnDictionaryValueMethodWithErrorCallback(
scoped_ptr<base::Value> value(dbus::PopDataAsValue(&reader));
base::DictionaryValue* result = NULL;
if (!value.get() || !value->GetAsDictionary(&result)) {
- const std::string error_name; // No error name.
- const std::string error_message = "Invalid response.";
- error_callback.Run(error_name, error_message);
+ error_callback.Run(kInvalidResponseErrorName, kInvalidResponseErrorMessage);
return;
}
callback.Run(*result);
diff --git a/chromeos/dbus/shill_client_helper.h b/chromeos/dbus/shill_client_helper.h
index a0225d0..8782d90 100644
--- a/chromeos/dbus/shill_client_helper.h
+++ b/chromeos/dbus/shill_client_helper.h
@@ -79,6 +79,12 @@ class ShillClientHelper {
void CallObjectPathMethod(dbus::MethodCall* method_call,
const ObjectPathDBusMethodCallback& callback);
+ // Calls a method with an object path result where there is an error callback.
+ void CallObjectPathMethodWithErrorCallback(
+ dbus::MethodCall* method_call,
+ const ObjectPathCallback& callback,
+ const ErrorCallback& error_callback);
+
// Calls a method with a dictionary value result.
void CallDictionaryValueMethod(dbus::MethodCall* method_call,
const DictionaryValueCallback& callback);
@@ -128,6 +134,12 @@ class ShillClientHelper {
void OnObjectPathMethod(const ObjectPathDBusMethodCallback& callback,
dbus::Response* response);
+ // Handles responses for methods with ObjectPath results.
+ void OnObjectPathMethodWithoutStatus(
+ const ObjectPathCallback& callback,
+ const ErrorCallback& error_callback,
+ dbus::Response* response);
+
// Handles responses for methods with DictionaryValue results.
void OnDictionaryValueMethod(const DictionaryValueCallback& callback,
dbus::Response* response);
diff --git a/chromeos/dbus/shill_client_unittest_base.cc b/chromeos/dbus/shill_client_unittest_base.cc
index 2a7eb3c..1907cb0 100644
--- a/chromeos/dbus/shill_client_unittest_base.cc
+++ b/chromeos/dbus/shill_client_unittest_base.cc
@@ -226,11 +226,16 @@ void ShillClientUnittestBase::ExpectObjectPathResult(
}
// static
-void ShillClientUnittestBase::ExpectDictionaryValueResult(
+void ShillClientUnittestBase::ExpectObjectPathResultWithoutStatus(
+ const dbus::ObjectPath& expected_result,
+ const dbus::ObjectPath& result) {
+ EXPECT_EQ(expected_result, result);
+}
+
+// static
+void ShillClientUnittestBase::ExpectDictionaryValueResultWithoutStatus(
const base::DictionaryValue* expected_result,
- DBusMethodCallStatus call_status,
const base::DictionaryValue& result) {
- EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status);
std::string expected_result_string;
base::JSONWriter::Write(expected_result, &expected_result_string);
std::string result_string;
@@ -238,6 +243,15 @@ void ShillClientUnittestBase::ExpectDictionaryValueResult(
EXPECT_EQ(expected_result_string, result_string);
}
+// static
+void ShillClientUnittestBase::ExpectDictionaryValueResult(
+ const base::DictionaryValue* expected_result,
+ DBusMethodCallStatus call_status,
+ const base::DictionaryValue& result) {
+ EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status);
+ ExpectDictionaryValueResultWithoutStatus(expected_result, result);
+}
+
void ShillClientUnittestBase::OnConnectToSignal(
const std::string& interface_name,
const std::string& signal_name,
diff --git a/chromeos/dbus/shill_client_unittest_base.h b/chromeos/dbus/shill_client_unittest_base.h
index 22bfb6f..96f4e93 100644
--- a/chromeos/dbus/shill_client_unittest_base.h
+++ b/chromeos/dbus/shill_client_unittest_base.h
@@ -140,11 +140,21 @@ class ShillClientUnittestBase : public testing::Test {
const dbus::ObjectPath& result);
// Checks the result and expects the call status to be SUCCESS.
+ static void ExpectObjectPathResultWithoutStatus(
+ const dbus::ObjectPath& expected_result,
+ const dbus::ObjectPath& result);
+
+ // Checks the result and expects the call status to be SUCCESS.
static void ExpectDictionaryValueResult(
const base::DictionaryValue* expected_result,
DBusMethodCallStatus call_status,
const base::DictionaryValue& result);
+ // Expects the |expected_result| to match the |result|.
+ static void ExpectDictionaryValueResultWithoutStatus(
+ const base::DictionaryValue* expected_result,
+ const base::DictionaryValue& result);
+
// A message loop to emulate asynchronous behavior.
MessageLoop message_loop_;
// The mock bus.
diff --git a/chromeos/dbus/shill_device_client.cc b/chromeos/dbus/shill_device_client.cc
index 9e29101..b2cc011 100644
--- a/chromeos/dbus/shill_device_client.cc
+++ b/chromeos/dbus/shill_device_client.cc
@@ -67,13 +67,16 @@ class ShillDeviceClientImpl : public ShillDeviceClient {
virtual void SetProperty(const dbus::ObjectPath& device_path,
const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface,
flimflam::kSetPropertyFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(name);
ShillClientHelper::AppendValueDataAsVariant(&writer, value);
- GetHelper(device_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(device_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual void ClearProperty(const dbus::ObjectPath& device_path,
@@ -281,14 +284,20 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient {
virtual void SetProperty(const dbus::ObjectPath& device_path,
const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
base::DictionaryValue* device_properties = NULL;
if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) {
- PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE);
+ std::string error_name("org.chromium.flimflam.Error.Failure");
+ std::string error_message("Failed");
+ MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(error_callback,
+ error_name,
+ error_message));
return;
}
device_properties->Set(name, value.DeepCopy());
- PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS);
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
virtual void ClearProperty(const dbus::ObjectPath& device_path,
diff --git a/chromeos/dbus/shill_device_client.h b/chromeos/dbus/shill_device_client.h
index c4e808c..7ac7e20 100644
--- a/chromeos/dbus/shill_device_client.h
+++ b/chromeos/dbus/shill_device_client.h
@@ -81,7 +81,8 @@ class CHROMEOS_EXPORT ShillDeviceClient {
virtual void SetProperty(const dbus::ObjectPath& device_path,
const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls ClearProperty method.
// |callback| is called after the method call finishes.
diff --git a/chromeos/dbus/shill_device_client_unittest.cc b/chromeos/dbus/shill_device_client_unittest.cc
index ef85d20..8f504f5 100644
--- a/chromeos/dbus/shill_device_client_unittest.cc
+++ b/chromeos/dbus/shill_device_client_unittest.cc
@@ -196,10 +196,16 @@ TEST_F(ShillDeviceClientTest, SetProperty) {
&value),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->SetProperty(dbus::ObjectPath(kExampleDevicePath),
flimflam::kCellularAllowRoamingProperty,
value,
- base::Bind(&ExpectNoResultValue));
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -272,6 +278,7 @@ TEST_F(ShillDeviceClientTest, RequirePin) {
kRequired),
response.get());
EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
// Call method.
client_->RequirePin(dbus::ObjectPath(kExampleDevicePath),
kPin,
@@ -295,6 +302,8 @@ TEST_F(ShillDeviceClientTest, EnterPin) {
kPin),
response.get());
EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Call method.
client_->EnterPin(dbus::ObjectPath(kExampleDevicePath),
kPin,
@@ -317,6 +326,8 @@ TEST_F(ShillDeviceClientTest, UnblockPin) {
base::Bind(&ExpectTwoStringArguments, kPuk, kPin),
response.get());
EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Call method.
client_->UnblockPin(dbus::ObjectPath(kExampleDevicePath),
kPuk,
@@ -342,6 +353,8 @@ TEST_F(ShillDeviceClientTest, ChangePin) {
kNewPin),
response.get());
EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Call method.
client_->ChangePin(dbus::ObjectPath(kExampleDevicePath),
kOldPin,
@@ -364,6 +377,8 @@ TEST_F(ShillDeviceClientTest, Register) {
base::Bind(&ExpectStringArgument, kNetworkId),
response.get());
EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Call method.
client_->Register(dbus::ObjectPath(kExampleDevicePath),
kNetworkId,
diff --git a/chromeos/dbus/shill_manager_client.cc b/chromeos/dbus/shill_manager_client.cc
index deb560b..08f163b 100644
--- a/chromeos/dbus/shill_manager_client.cc
+++ b/chromeos/dbus/shill_manager_client.cc
@@ -84,63 +84,81 @@ class ShillManagerClientImpl : public ShillManagerClient {
virtual void SetProperty(const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
flimflam::kSetPropertyFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(name);
ShillClientHelper::AppendValueDataAsVariant(&writer, value);
- helper_.CallVoidMethod(&method_call, callback);
+ helper_.CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual void RequestScan(const std::string& type,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
flimflam::kRequestScanFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(type);
- helper_.CallVoidMethod(&method_call, callback);
+ helper_.CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual void EnableTechnology(
const std::string& type,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
flimflam::kEnableTechnologyFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(type);
- helper_.CallVoidMethod(&method_call, callback);
+ helper_.CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual void DisableTechnology(
const std::string& type,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
flimflam::kDisableTechnologyFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(type);
- helper_.CallVoidMethod(&method_call, callback);
+ helper_.CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual void ConfigureService(
const base::DictionaryValue& properties,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
DCHECK(AreServicePropertiesValid(properties));
dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
flimflam::kConfigureServiceFunction);
dbus::MessageWriter writer(&method_call);
AppendServicePropertiesDictionary(&writer, properties);
- helper_.CallVoidMethod(&method_call, callback);
+ helper_.CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual void GetService(
const base::DictionaryValue& properties,
- const ObjectPathDBusMethodCallback& callback) OVERRIDE {
+ const ObjectPathCallback& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface,
flimflam::kGetServiceFunction);
dbus::MessageWriter writer(&method_call);
AppendServicePropertiesDictionary(&writer, properties);
- helper_.CallObjectPathMethod(&method_call, callback);
+ helper_.CallObjectPathMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
private:
@@ -191,55 +209,50 @@ class ShillManagerClientStubImpl : public ShillManagerClient {
// ShillManagerClient override.
virtual void SetProperty(const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
stub_properties_.Set(name, value.DeepCopy());
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback,
- DBUS_METHOD_CALL_SUCCESS));
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
// ShillManagerClient override.
virtual void RequestScan(const std::string& type,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback,
- DBUS_METHOD_CALL_SUCCESS));
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
// ShillManagerClient override.
virtual void EnableTechnology(
const std::string& type,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback,
- DBUS_METHOD_CALL_SUCCESS));
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
// ShillManagerClient override.
virtual void DisableTechnology(
const std::string& type,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback,
- DBUS_METHOD_CALL_SUCCESS));
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
// ShillManagerClient override.
virtual void ConfigureService(
const base::DictionaryValue& properties,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback,
- DBUS_METHOD_CALL_SUCCESS));
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
// ShillManagerClient override.
virtual void GetService(
const base::DictionaryValue& properties,
- const ObjectPathDBusMethodCallback& callback) OVERRIDE {
+ const ObjectPathCallback& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(callback,
- DBUS_METHOD_CALL_SUCCESS,
dbus::ObjectPath()));
}
diff --git a/chromeos/dbus/shill_manager_client.h b/chromeos/dbus/shill_manager_client.h
index 195b230..8034830 100644
--- a/chromeos/dbus/shill_manager_client.h
+++ b/chromeos/dbus/shill_manager_client.h
@@ -30,6 +30,7 @@ class CHROMEOS_EXPORT ShillManagerClient {
public:
typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback;
+ typedef ShillClientHelper::ErrorCallback ErrorCallback;
virtual ~ShillManagerClient();
@@ -62,32 +63,38 @@ class CHROMEOS_EXPORT ShillManagerClient {
// |callback| is called after the method call succeeds.
virtual void SetProperty(const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls RequestScan method.
// |callback| is called after the method call succeeds.
virtual void RequestScan(const std::string& type,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls EnableTechnology method.
// |callback| is called after the method call succeeds.
virtual void EnableTechnology(const std::string& type,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls DisableTechnology method.
// |callback| is called after the method call succeeds.
virtual void DisableTechnology(const std::string& type,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls ConfigureService method.
// |callback| is called after the method call succeeds.
virtual void ConfigureService(const base::DictionaryValue& properties,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls GetService method.
// |callback| is called after the method call succeeds.
virtual void GetService(const base::DictionaryValue& properties,
- const ObjectPathDBusMethodCallback& callback) = 0;
+ const ObjectPathCallback& callback,
+ const ErrorCallback& error_callback) = 0;
protected:
// Create() should be used instead.
diff --git a/chromeos/dbus/shill_manager_client_unittest.cc b/chromeos/dbus/shill_manager_client_unittest.cc
index e101bf2..b80d8d9 100644
--- a/chromeos/dbus/shill_manager_client_unittest.cc
+++ b/chromeos/dbus/shill_manager_client_unittest.cc
@@ -221,9 +221,15 @@ TEST_F(ShillManagerClientTest, SetProperty) {
&value),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->SetProperty(flimflam::kCheckPortalListProperty,
value,
- base::Bind(&ExpectNoResultValue));
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -236,7 +242,14 @@ TEST_F(ShillManagerClientTest, RequestScan) {
base::Bind(&ExpectStringArgument, flimflam::kTypeWifi),
response.get());
// Call method.
- client_->RequestScan(flimflam::kTypeWifi, base::Bind(&ExpectNoResultValue));
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
+ client_->RequestScan(flimflam::kTypeWifi,
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -249,8 +262,14 @@ TEST_F(ShillManagerClientTest, EnableTechnology) {
base::Bind(&ExpectStringArgument, flimflam::kTypeWifi),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->EnableTechnology(flimflam::kTypeWifi,
- base::Bind(&ExpectNoResultValue));
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -263,8 +282,14 @@ TEST_F(ShillManagerClientTest, DisableTechnology) {
base::Bind(&ExpectStringArgument, flimflam::kTypeWifi),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->DisableTechnology(flimflam::kTypeWifi,
- base::Bind(&ExpectNoResultValue));
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -279,7 +304,14 @@ TEST_F(ShillManagerClientTest, ConfigureService) {
base::Bind(&ExpectDictionaryValueArgument, arg.get()),
response.get());
// Call method.
- client_->ConfigureService(*arg, base::Bind(&ExpectNoResultValue));
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
+ client_->ConfigureService(*arg,
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -297,7 +329,13 @@ TEST_F(ShillManagerClientTest, GetService) {
base::Bind(&ExpectDictionaryValueArgument, arg.get()),
response.get());
// Call method.
- client_->GetService(*arg, base::Bind(&ExpectObjectPathResult, object_path));
+ MockErrorCallback mock_error_callback;
+ client_->GetService(*arg,
+ base::Bind(&ExpectObjectPathResultWithoutStatus,
+ object_path),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
diff --git a/chromeos/dbus/shill_profile_client.cc b/chromeos/dbus/shill_profile_client.cc
index 70e5b20..6b2544c 100644
--- a/chromeos/dbus/shill_profile_client.cc
+++ b/chromeos/dbus/shill_profile_client.cc
@@ -37,14 +37,18 @@ class ShillProfileClientImpl : public ShillProfileClient {
ShillPropertyChangedObserver* observer) OVERRIDE {
GetHelper(profile_path)->RemovePropertyChangedObserver(observer);
}
- virtual void GetProperties(const dbus::ObjectPath& profile_path,
- const DictionaryValueCallback& callback) OVERRIDE;
+ virtual void GetProperties(
+ const dbus::ObjectPath& profile_path,
+ const DictionaryValueCallbackWithoutStatus& callback,
+ const ErrorCallback& error_callback) OVERRIDE;
virtual void GetEntry(const dbus::ObjectPath& profile_path,
const std::string& entry_path,
- const DictionaryValueCallback& callback) OVERRIDE;
+ const DictionaryValueCallbackWithoutStatus& callback,
+ const ErrorCallback& error_callback) OVERRIDE;
virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
const std::string& entry_path,
- const VoidDBusMethodCallback& callback) OVERRIDE;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE;
private:
typedef std::map<std::string, ShillClientHelper*> HelperMap;
@@ -81,32 +85,38 @@ ShillClientHelper* ShillProfileClientImpl::GetHelper(
void ShillProfileClientImpl::GetProperties(
const dbus::ObjectPath& profile_path,
- const DictionaryValueCallback& callback) {
+ const DictionaryValueCallbackWithoutStatus& callback,
+ const ErrorCallback& error_callback) {
dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface,
flimflam::kGetPropertiesFunction);
- GetHelper(profile_path)->CallDictionaryValueMethod(&method_call, callback);
+ GetHelper(profile_path)->CallDictionaryValueMethodWithErrorCallback(
+ &method_call, callback, error_callback);
}
void ShillProfileClientImpl::GetEntry(
const dbus::ObjectPath& profile_path,
const std::string& entry_path,
- const DictionaryValueCallback& callback) {
+ const DictionaryValueCallbackWithoutStatus& callback,
+ const ErrorCallback& error_callback) {
dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface,
flimflam::kGetEntryFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(entry_path);
- GetHelper(profile_path)->CallDictionaryValueMethod(&method_call, callback);
+ GetHelper(profile_path)->CallDictionaryValueMethodWithErrorCallback(
+ &method_call, callback, error_callback);
}
void ShillProfileClientImpl::DeleteEntry(
const dbus::ObjectPath& profile_path,
const std::string& entry_path,
- const VoidDBusMethodCallback& callback) {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface,
flimflam::kDeleteEntryFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(entry_path);
- GetHelper(profile_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(profile_path)->CallVoidMethodWithErrorCallback(
+ &method_call, callback, error_callback);
}
// A stub implementation of ShillProfileClient.
@@ -126,9 +136,10 @@ class ShillProfileClientStubImpl : public ShillProfileClient {
const dbus::ObjectPath& profile_path,
ShillPropertyChangedObserver* observer) OVERRIDE {}
- // ShillProfileClient override.
- virtual void GetProperties(const dbus::ObjectPath& profile_path,
- const DictionaryValueCallback& callback) OVERRIDE {
+ virtual void GetProperties(
+ const dbus::ObjectPath& profile_path,
+ const DictionaryValueCallbackWithoutStatus& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&ShillProfileClientStubImpl::PassEmptyDictionaryValue,
@@ -138,7 +149,8 @@ class ShillProfileClientStubImpl : public ShillProfileClient {
virtual void GetEntry(const dbus::ObjectPath& profile_path,
const std::string& entry_path,
- const DictionaryValueCallback& callback) OVERRIDE {
+ const DictionaryValueCallbackWithoutStatus& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&ShillProfileClientStubImpl::PassEmptyDictionaryValue,
@@ -148,16 +160,16 @@ class ShillProfileClientStubImpl : public ShillProfileClient {
virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
const std::string& entry_path,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback,
- DBUS_METHOD_CALL_SUCCESS));
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
private:
- void PassEmptyDictionaryValue(const DictionaryValueCallback& callback) const {
+ void PassEmptyDictionaryValue(
+ const DictionaryValueCallbackWithoutStatus& callback) const {
base::DictionaryValue dictionary;
- callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary);
+ callback.Run(dictionary);
}
// Note: This should remain the last member so it'll be destroyed and
diff --git a/chromeos/dbus/shill_profile_client.h b/chromeos/dbus/shill_profile_client.h
index ece50d4..2c45ac7 100644
--- a/chromeos/dbus/shill_profile_client.h
+++ b/chromeos/dbus/shill_profile_client.h
@@ -37,7 +37,9 @@ class ShillPropertyChangedObserver;
class CHROMEOS_EXPORT ShillProfileClient {
public:
typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
- typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback;
+ typedef ShillClientHelper::DictionaryValueCallbackWithoutStatus
+ DictionaryValueCallbackWithoutStatus;
+ typedef ShillClientHelper::ErrorCallback ErrorCallback;
virtual ~ShillProfileClient();
@@ -58,20 +60,24 @@ class CHROMEOS_EXPORT ShillProfileClient {
// Calls GetProperties method.
// |callback| is called after the method call succeeds.
- virtual void GetProperties(const dbus::ObjectPath& profile_path,
- const DictionaryValueCallback& callback) = 0;
+ virtual void GetProperties(
+ const dbus::ObjectPath& profile_path,
+ const DictionaryValueCallbackWithoutStatus& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls GetEntry method.
// |callback| is called after the method call succeeds.
virtual void GetEntry(const dbus::ObjectPath& profile_path,
const std::string& entry_path,
- const DictionaryValueCallback& callback) = 0;
+ const DictionaryValueCallbackWithoutStatus& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls DeleteEntry method.
// |callback| is called after the method call succeeds.
virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
const std::string& entry_path,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
protected:
// Create() should be used instead.
diff --git a/chromeos/dbus/shill_profile_client_unittest.cc b/chromeos/dbus/shill_profile_client_unittest.cc
index 5e024a1..47d6cc0 100644
--- a/chromeos/dbus/shill_profile_client_unittest.cc
+++ b/chromeos/dbus/shill_profile_client_unittest.cc
@@ -116,8 +116,13 @@ TEST_F(ShillProfileClientTest, GetProperties) {
base::Bind(&ExpectNoArgument),
response.get());
// Call method.
+ MockErrorCallback error_callback;
client_->GetProperties(dbus::ObjectPath(kDefaultProfilePath),
- base::Bind(&ExpectDictionaryValueResult, &value));
+ base::Bind(&ExpectDictionaryValueResultWithoutStatus,
+ &value),
+ error_callback.GetCallback());
+ EXPECT_CALL(error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -145,9 +150,13 @@ TEST_F(ShillProfileClientTest, GetEntry) {
base::Bind(&ExpectStringArgument, kExampleEntryPath),
response.get());
// Call method.
+ MockErrorCallback error_callback;
client_->GetEntry(dbus::ObjectPath(kDefaultProfilePath),
kExampleEntryPath,
- base::Bind(&ExpectDictionaryValueResult, &value));
+ base::Bind(&ExpectDictionaryValueResultWithoutStatus,
+ &value),
+ error_callback.GetCallback());
+ EXPECT_CALL(error_callback, Run(_, _)).Times(0);
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -165,9 +174,15 @@ TEST_F(ShillProfileClientTest, DeleteEntry) {
base::Bind(&ExpectStringArgument, kExampleEntryPath),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath),
kExampleEntryPath,
- base::Bind(&ExpectNoResultValue));
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
diff --git a/chromeos/dbus/shill_service_client.cc b/chromeos/dbus/shill_service_client.cc
index 6a1c617..46fe0f4 100644
--- a/chromeos/dbus/shill_service_client.cc
+++ b/chromeos/dbus/shill_service_client.cc
@@ -75,23 +75,29 @@ class ShillServiceClientImpl : public ShillServiceClient {
virtual void SetProperty(const dbus::ObjectPath& service_path,
const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
flimflam::kSetPropertyFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(name);
ShillClientHelper::AppendValueDataAsVariant(&writer, value);
- GetHelper(service_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual void ClearProperty(const dbus::ObjectPath& service_path,
const std::string& name,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
flimflam::kClearPropertyFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(name);
- GetHelper(service_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual void Connect(const dbus::ObjectPath& service_path,
@@ -104,28 +110,37 @@ class ShillServiceClientImpl : public ShillServiceClient {
}
virtual void Disconnect(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
flimflam::kDisconnectFunction);
- GetHelper(service_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual void Remove(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
flimflam::kRemoveServiceFunction);
- GetHelper(service_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual void ActivateCellularModem(
const dbus::ObjectPath& service_path,
const std::string& carrier,
- const VoidDBusMethodCallback& callback) OVERRIDE {
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface,
flimflam::kActivateCellularModemFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(carrier);
- GetHelper(service_path)->CallVoidMethod(&method_call, callback);
+ GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call,
+ callback,
+ error_callback);
}
virtual bool CallActivateCellularModemAndBlock(
@@ -192,14 +207,16 @@ class ShillServiceClientStubImpl : public ShillServiceClient {
virtual void SetProperty(const dbus::ObjectPath& service_path,
const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- PostSuccessVoidCallback(callback);
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
virtual void ClearProperty(const dbus::ObjectPath& service_path,
const std::string& name,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- PostSuccessVoidCallback(callback);
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
virtual void Connect(const dbus::ObjectPath& service_path,
@@ -209,20 +226,23 @@ class ShillServiceClientStubImpl : public ShillServiceClient {
}
virtual void Disconnect(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- PostSuccessVoidCallback(callback);
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
virtual void Remove(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- PostSuccessVoidCallback(callback);
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
virtual void ActivateCellularModem(
const dbus::ObjectPath& service_path,
const std::string& carrier,
- const VoidDBusMethodCallback& callback) OVERRIDE {
- PostSuccessVoidCallback(callback);
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ MessageLoop::current()->PostTask(FROM_HERE, callback);
}
virtual bool CallActivateCellularModemAndBlock(
@@ -237,13 +257,6 @@ class ShillServiceClientStubImpl : public ShillServiceClient {
callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary);
}
- // Posts a task to run a void callback with success status code.
- void PostSuccessVoidCallback(const VoidDBusMethodCallback& callback) {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback,
- DBUS_METHOD_CALL_SUCCESS));
- }
-
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<ShillServiceClientStubImpl> weak_ptr_factory_;
diff --git a/chromeos/dbus/shill_service_client.h b/chromeos/dbus/shill_service_client.h
index 7f0cf1c..0e30243 100644
--- a/chromeos/dbus/shill_service_client.h
+++ b/chromeos/dbus/shill_service_client.h
@@ -66,13 +66,15 @@ class CHROMEOS_EXPORT ShillServiceClient {
virtual void SetProperty(const dbus::ObjectPath& service_path,
const std::string& name,
const base::Value& value,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls ClearProperty method.
// |callback| is called after the method call succeeds.
virtual void ClearProperty(const dbus::ObjectPath& service_path,
const std::string& name,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls Connect method.
// |callback| is called after the method call succeeds.
@@ -83,19 +85,22 @@ class CHROMEOS_EXPORT ShillServiceClient {
// Calls Disconnect method.
// |callback| is called after the method call succeeds.
virtual void Disconnect(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls Remove method.
// |callback| is called after the method call succeeds.
virtual void Remove(const dbus::ObjectPath& service_path,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// Calls ActivateCellularModem method.
// |callback| is called after the method call succeeds.
virtual void ActivateCellularModem(
const dbus::ObjectPath& service_path,
const std::string& carrier,
- const VoidDBusMethodCallback& callback) = 0;
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
// DEPRECATED DO NOT USE: Calls ActivateCellularModem method and blocks until
// the method call finishes.
diff --git a/chromeos/dbus/shill_service_client_unittest.cc b/chromeos/dbus/shill_service_client_unittest.cc
index c951075..93a9731 100644
--- a/chromeos/dbus/shill_service_client_unittest.cc
+++ b/chromeos/dbus/shill_service_client_unittest.cc
@@ -124,10 +124,16 @@ TEST_F(ShillServiceClientTest, SetProperty) {
&value),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->SetProperty(dbus::ObjectPath(kExampleServicePath),
flimflam::kPassphraseProperty,
value,
- base::Bind(&ExpectNoResultValue));
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -142,9 +148,15 @@ TEST_F(ShillServiceClientTest, ClearProperty) {
flimflam::kPassphraseProperty),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->ClearProperty(dbus::ObjectPath(kExampleServicePath),
flimflam::kPassphraseProperty,
- base::Bind(&ExpectNoResultValue));
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -178,8 +190,14 @@ TEST_F(ShillServiceClientTest, Disconnect) {
base::Bind(&ExpectNoArgument),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->Disconnect(dbus::ObjectPath(kExampleServicePath),
- base::Bind(&ExpectNoResultValue));
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -193,8 +211,14 @@ TEST_F(ShillServiceClientTest, Remove) {
base::Bind(&ExpectNoArgument),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->Remove(dbus::ObjectPath(kExampleServicePath),
- base::Bind(&ExpectNoResultValue));
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}
@@ -209,9 +233,15 @@ TEST_F(ShillServiceClientTest, ActivateCellularModem) {
base::Bind(&ExpectStringArgument, kCarrier),
response.get());
// Call method.
+ MockClosure mock_closure;
+ MockErrorCallback mock_error_callback;
client_->ActivateCellularModem(dbus::ObjectPath(kExampleServicePath),
kCarrier,
- base::Bind(&ExpectNoResultValue));
+ mock_closure.GetCallback(),
+ mock_error_callback.GetCallback());
+ EXPECT_CALL(mock_closure, Run()).Times(1);
+ EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
+
// Run the message loop.
message_loop_.RunAllPending();
}