summaryrefslogtreecommitdiffstats
path: root/dbus/object_proxy.cc
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-23 06:55:22 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-23 06:55:22 +0000
commitca72ff29277e39031e2b409e2a593b25d0066e8a (patch)
treebfadc8aeb37312310f8743ae4ff5e9a631c1c625 /dbus/object_proxy.cc
parentf9cb2108d32497ca7688db99f144e0dbe73537da (diff)
downloadchromium_src-ca72ff29277e39031e2b409e2a593b25d0066e8a.zip
chromium_src-ca72ff29277e39031e2b409e2a593b25d0066e8a.tar.gz
chromium_src-ca72ff29277e39031e2b409e2a593b25d0066e8a.tar.bz2
Change setters of dbus::Message to return false instead of aborting on errors
With this change, we can safely return error for invalid object path and service name. It still crashes on invalid method name and interface name if we use MethodCall::MethodCall for setting those parameters. BUG=128967 TEST=dbus_unittests Review URL: https://chromiumcodereview.appspot.com/10409065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/object_proxy.cc')
-rw-r--r--dbus/object_proxy.cc25
1 files changed, 19 insertions, 6 deletions
diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc
index 051d8f1..4d7aa25 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,