summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authorharuki@chromium.org <haruki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 11:57:14 +0000
committerharuki@chromium.org <haruki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 11:57:14 +0000
commit45f23e891232e925a1fb32485ebbd0fbd7769884 (patch)
treebc84ba2d85d1f2416b505f2e213e743cf3d7a1e6 /dbus
parent9cbc4f0b3af0dd7cc1f1999478c4e28a7b2a0fc9 (diff)
downloadchromium_src-45f23e891232e925a1fb32485ebbd0fbd7769884.zip
chromium_src-45f23e891232e925a1fb32485ebbd0fbd7769884.tar.gz
chromium_src-45f23e891232e925a1fb32485ebbd0fbd7769884.tar.bz2
dbus: adding PostTaskToDBusThreadAndReply
This CL only adds a util method. BUG=172821 TEST=unittests R=satorux@chromium.org Review URL: https://codereview.chromium.org/14985008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198876 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus')
-rw-r--r--dbus/bus.cc18
-rw-r--r--dbus/bus.h7
2 files changed, 25 insertions, 0 deletions
diff --git a/dbus/bus.cc b/dbus/bus.cc
index 0d170ff..fafacd3 100644
--- a/dbus/bus.cc
+++ b/dbus/bus.cc
@@ -775,6 +775,24 @@ void Bus::ProcessAllIncomingDataIfAny() {
}
}
+void Bus::PostTaskToDBusThreadAndReply(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ const base::Closure& reply) {
+ AssertOnOriginThread();
+
+ if (dbus_task_runner_.get()) {
+ if (!dbus_task_runner_->PostTaskAndReply(from_here, task, reply)) {
+ LOG(WARNING) << "Failed to post a task to the D-Bus thread message loop";
+ }
+ } else {
+ DCHECK(origin_task_runner_.get());
+ if (!origin_task_runner_->PostTaskAndReply(from_here, task, reply)) {
+ LOG(WARNING) << "Failed to post a task to the origin message loop";
+ }
+ }
+}
+
void Bus::PostTaskToOriginThread(const tracked_objects::Location& from_here,
const base::Closure& task) {
DCHECK(origin_task_runner_.get());
diff --git a/dbus/bus.h b/dbus/bus.h
index 5cf73ac..03e2aa5 100644
--- a/dbus/bus.h
+++ b/dbus/bus.h
@@ -511,6 +511,13 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> {
// BLOCKING CALL.
virtual void UnregisterObjectPath(const ObjectPath& object_path);
+ // Posts |task| to the task runner of the D-Bus thread. On completion, |reply|
+ // is posted to the origin thread.
+ virtual void PostTaskToDBusThreadAndReply(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ const base::Closure& reply);
+
// Posts the task to the task runner of the thread that created the bus.
virtual void PostTaskToOriginThread(
const tracked_objects::Location& from_here,