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

Unified Diff: dbus/object_proxy.cc

Issue 10409065: Change setters of dbus::Message to return false instead of aborting on errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: _ Created 8 years, 7 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 | « dbus/message_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/object_proxy.cc
diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc
index 051d8f177fdf2110d13ca2ee9499bd7df9d1df77..4d7aa250db2db15d6d2d24064b1bf7f416b45323 100644
--- a/dbus/object_proxy.cc
+++ b/dbus/object_proxy.cc
@@ -63,11 +63,11 @@ Response* ObjectProxy::CallMethodAndBlock(MethodCall* method_call,
int timeout_ms) {
bus_->AssertOnDBusThread();
- if (!bus_->Connect())
+ if (!bus_->Connect() ||
+ !method_call->SetDestination(service_name_) ||
+ !method_call->SetPath(object_path_))
return NULL;
- method_call->SetDestination(service_name_);
- method_call->SetPath(object_path_);
DBusMessage* request_message = method_call->raw_message();
ScopedDBusError error;
@@ -108,15 +108,28 @@ void ObjectProxy::CallMethodWithErrorCallback(MethodCall* method_call,
ErrorCallback error_callback) {
bus_->AssertOnOriginThread();
- method_call->SetDestination(service_name_);
- method_call->SetPath(object_path_);
+ const base::TimeTicks start_time = base::TimeTicks::Now();
+
+ if (!method_call->SetDestination(service_name_) ||
+ !method_call->SetPath(object_path_)) {
+ // In case of a failure, run the error callback with NULL.
+ DBusMessage* response_message = NULL;
+ base::Closure task = base::Bind(&ObjectProxy::RunResponseCallback,
+ this,
+ callback,
+ error_callback,
+ start_time,
+ response_message);
+ bus_->PostTaskToOriginThread(FROM_HERE, task);
+ return;
+ }
+
// Increment the reference count so we can safely reference the
// underlying request message until the method call is complete. This
// will be unref'ed in StartAsyncMethodCall().
DBusMessage* request_message = method_call->raw_message();
dbus_message_ref(request_message);
- const base::TimeTicks start_time = base::TimeTicks::Now();
base::Closure task = base::Bind(&ObjectProxy::StartAsyncMethodCall,
this,
timeout_ms,
« no previous file with comments | « dbus/message_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698