Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: chromeos/dbus/shill_client_helper.cc

Issue 10949030: This converts the Shill clients to allow propagation of shill errors (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: review changes Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/shill_client_helper.cc
diff --git a/chromeos/dbus/shill_client_helper.cc b/chromeos/dbus/shill_client_helper.cc
index bd421bcfa453f26f02bd5b809d0dc0f2038d275a..55c7b70f95db9c14d7160bde66e0458662544611 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),
@@ -62,6 +69,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) {
@@ -230,6 +253,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) {
@@ -263,9 +303,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);

Powered by Google App Engine
This is Rietveld 408576698