summaryrefslogtreecommitdiffstats
path: root/dbus/exported_object.cc
diff options
context:
space:
mode:
authorvlaviano@chromium.org <vlaviano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-30 04:57:42 +0000
committervlaviano@chromium.org <vlaviano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-30 04:57:42 +0000
commit9aa74ccbcaf9f29f03ca4f0dbccd896ef4098118 (patch)
tree353aaadbdf70b223d8e0cbe71572bd9814c7e580 /dbus/exported_object.cc
parentcb8a5468be6eb5072a8e9173b554448c0d06e111 (diff)
downloadchromium_src-9aa74ccbcaf9f29f03ca4f0dbccd896ef4098118.zip
chromium_src-9aa74ccbcaf9f29f03ca4f0dbccd896ef4098118.tar.gz
chromium_src-9aa74ccbcaf9f29f03ca4f0dbccd896ef4098118.tar.bz2
chrome: dbus: support asynchronous method replies
BUG=chromium-os:23241 TEST=Unit tests and manual testing on device. Change-Id: Iab009ddbd12dea1e12299ae0ddccd4e430d9cf97 Review URL: http://codereview.chromium.org/8728020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112131 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/exported_object.cc')
-rw-r--r--dbus/exported_object.cc40
1 files changed, 27 insertions, 13 deletions
diff --git a/dbus/exported_object.cc b/dbus/exported_object.cc
index e4a1641..de25168 100644
--- a/dbus/exported_object.cc
+++ b/dbus/exported_object.cc
@@ -224,12 +224,13 @@ DBusHandlerResult ExportedObject::HandleMessage(
method_call.release(),
start_time));
} else {
- // If the D-Bus thread is not used, just call the method directly. We
- // don't need the complicated logic to wait for the method call to be
- // complete.
- // |response| will be deleted in OnMethodCompleted().
- Response* response = iter->second.Run(method_call.get());
- OnMethodCompleted(method_call.release(), response, start_time);
+ // If the D-Bus thread is not used, just call the method directly.
+ MethodCall* released_method_call = method_call.release();
+ iter->second.Run(released_method_call,
+ base::Bind(&ExportedObject::SendResponse,
+ this,
+ start_time,
+ released_method_call));
}
// It's valid to say HANDLED here, and send a method response at a later
@@ -241,14 +242,27 @@ void ExportedObject::RunMethod(MethodCallCallback method_call_callback,
MethodCall* method_call,
base::TimeTicks start_time) {
bus_->AssertOnOriginThread();
+ method_call_callback.Run(method_call,
+ base::Bind(&ExportedObject::SendResponse,
+ this,
+ start_time,
+ method_call));
+}
- Response* response = method_call_callback.Run(method_call);
- bus_->PostTaskToDBusThread(FROM_HERE,
- base::Bind(&ExportedObject::OnMethodCompleted,
- this,
- method_call,
- response,
- start_time));
+void ExportedObject::SendResponse(base::TimeTicks start_time,
+ MethodCall* method_call,
+ Response* response) {
+ DCHECK(method_call);
+ if (bus_->HasDBusThread()) {
+ bus_->PostTaskToDBusThread(FROM_HERE,
+ base::Bind(&ExportedObject::OnMethodCompleted,
+ this,
+ method_call,
+ response,
+ start_time));
+ } else {
+ OnMethodCompleted(method_call, response, start_time);
+ }
}
void ExportedObject::OnMethodCompleted(MethodCall* method_call,