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

Unified Diff: dbus/exported_object.cc

Issue 8637002: chrome: dbus: support asynchronous method replies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory management issue in ExportedObject::HandleMessage Created 9 years, 1 month 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/exported_object.h ('k') | dbus/test_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/exported_object.cc
diff --git a/dbus/exported_object.cc b/dbus/exported_object.cc
index e4a1641fa6e5ee67692bd383da896237e07a139c..e5d012fe2fc845d184094ba0c2af216bef011db8 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* method_call_ptr = method_call.release();
satorux1 2011/11/23 23:31:46 method_call_ptr -> released_method_call may be a b
Vince Laviano 2011/11/24 00:14:13 Done.
+ iter->second.Run(method_call_ptr,
+ base::Bind(&ExportedObject::SendResponse,
+ this,
+ start_time,
+ method_call_ptr));
}
// 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,
« no previous file with comments | « dbus/exported_object.h ('k') | dbus/test_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698