Commit 45f23e89 authored by haruki@chromium.org's avatar haruki@chromium.org

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
parent 9cbc4f0b
...@@ -775,6 +775,24 @@ void Bus::ProcessAllIncomingDataIfAny() { ...@@ -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, void Bus::PostTaskToOriginThread(const tracked_objects::Location& from_here,
const base::Closure& task) { const base::Closure& task) {
DCHECK(origin_task_runner_.get()); DCHECK(origin_task_runner_.get());
......
...@@ -511,6 +511,13 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> { ...@@ -511,6 +511,13 @@ class CHROME_DBUS_EXPORT Bus : public base::RefCountedThreadSafe<Bus> {
// BLOCKING CALL. // BLOCKING CALL.
virtual void UnregisterObjectPath(const ObjectPath& object_path); 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. // Posts the task to the task runner of the thread that created the bus.
virtual void PostTaskToOriginThread( virtual void PostTaskToOriginThread(
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment