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

Unified Diff: chromeos/dbus/flimflam_client_helper.cc

Issue 10170020: Rework chromeos::FlimflamDevice/ServiceClient with CallMethodWithErrorCallback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 8 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
« no previous file with comments | « chromeos/dbus/flimflam_client_helper.h ('k') | chromeos/dbus/flimflam_client_unittest_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/flimflam_client_helper.cc
diff --git a/chromeos/dbus/flimflam_client_helper.cc b/chromeos/dbus/flimflam_client_helper.cc
index 97c91dd1d541eff45a61d4b884a4ba706e9584f3..89162cbfefcf818ae3aae9da1a4fcf4f58f454e8 100644
--- a/chromeos/dbus/flimflam_client_helper.cc
+++ b/chromeos/dbus/flimflam_client_helper.cc
@@ -70,6 +70,20 @@ void FlimflamClientHelper::CallDictionaryValueMethod(
callback));
}
+void FlimflamClientHelper::CallVoidMethodWithErrorCallback(
+ dbus::MethodCall* method_call,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ proxy_->CallMethodWithErrorCallback(
+ method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&FlimflamClientHelper::OnVoidMethodWithErrorCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback),
+ base::Bind(&FlimflamClientHelper::OnError,
+ weak_ptr_factory_.GetWeakPtr(),
+ error_callback));
+}
+
bool FlimflamClientHelper::CallVoidMethodAndBlock(
dbus::MethodCall* method_call) {
scoped_ptr<dbus::Response> response(
@@ -218,4 +232,23 @@ void FlimflamClientHelper::OnDictionaryValueMethod(
callback.Run(DBUS_METHOD_CALL_SUCCESS, *result);
}
+void FlimflamClientHelper::OnVoidMethodWithErrorCallback(
+ const base::Closure& callback,
+ dbus::Response* response) {
+ callback.Run();
+}
+
+void FlimflamClientHelper::OnError(const ErrorCallback& error_callback,
+ dbus::ErrorResponse* response) {
+ std::string error_name;
+ std::string error_message;
+ if (response) {
+ // Error message may contain the error message as string.
+ dbus::MessageReader reader(response);
+ error_name = response->GetErrorName();
+ reader.PopString(&error_message);
+ }
+ error_callback.Run(error_name, error_message);
+}
+
} // namespace chromeos
« no previous file with comments | « chromeos/dbus/flimflam_client_helper.h ('k') | chromeos/dbus/flimflam_client_unittest_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698