summaryrefslogtreecommitdiffstats
path: root/dbus/exported_object.cc
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-20 01:07:17 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-20 01:07:17 +0000
commit12f9766f28712f8ec3755db4558dba4db5bd8a70 (patch)
tree6ab911b0b85b1851bef201f25825911d4a66849e /dbus/exported_object.cc
parent940895b5308ace929396a87bd13cf0764f0c16e2 (diff)
downloadchromium_src-12f9766f28712f8ec3755db4558dba4db5bd8a70.zip
chromium_src-12f9766f28712f8ec3755db4558dba4db5bd8a70.tar.gz
chromium_src-12f9766f28712f8ec3755db4558dba4db5bd8a70.tar.bz2
Rework TestService using asynchronos API of ExportedObject.
This change is to to exercise asynchronos API of ExportedObject. The asynchronos API is implemented on top the synchronos API, hence the synchronos API code is also covered. Along the way, change EndToEndAsyncTest to use the D-Bus thread. Simplified the test code per phajdan.jr's comments as well. TEST=dbus_unittests BUG=90036 Review URL: http://codereview.chromium.org/7671028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/exported_object.cc')
-rw-r--r--dbus/exported_object.cc20
1 files changed, 7 insertions, 13 deletions
diff --git a/dbus/exported_object.cc b/dbus/exported_object.cc
index 1793ed2..2ac1ff0 100644
--- a/dbus/exported_object.cc
+++ b/dbus/exported_object.cc
@@ -36,9 +36,9 @@ ExportedObject::ExportedObject(Bus* bus,
service_name_(service_name),
object_path_(object_path),
object_is_registered_(false),
- method_is_called_(false),
response_from_method_(NULL),
- on_method_is_called_(&method_is_called_lock_) {
+ on_method_is_called_(false /* manual_reset */,
+ false /* initially_signaled */) {
}
ExportedObject::~ExportedObject() {
@@ -180,7 +180,6 @@ DBusHandlerResult ExportedObject::HandleMessage(
Response* response = NULL;
if (bus_->HasDBusThread()) {
response_from_method_ = NULL;
- method_is_called_ = false;
// Post a task to run the method in the origin thread.
bus_->PostTaskToOriginThread(FROM_HERE,
base::Bind(&ExportedObject::RunMethod,
@@ -195,14 +194,11 @@ DBusHandlerResult ExportedObject::HandleMessage(
const int kTimeoutSecs = 10;
const base::TimeDelta timeout(
base::TimeDelta::FromSeconds(kTimeoutSecs));
- const base::Time start_time = base::Time::Now();
-
- base::AutoLock auto_lock(method_is_called_lock_);
- while (!method_is_called_) {
- on_method_is_called_.TimedWait(timeout);
- CHECK(base::Time::Now() - start_time < timeout)
- << "Method " << absolute_method_name << " timed out";
- }
+
+ const bool signaled = on_method_is_called_.TimedWait(timeout);
+ // Method not called is a fatal error. The method is likely stuck
+ // infinitely in the origin thread. No way to stop it from here.
+ CHECK(signaled) << "Method " << absolute_method_name << " not called";
}
response = response_from_method_;
} else {
@@ -233,9 +229,7 @@ void ExportedObject::RunMethod(MethodCallCallback method_call_callback,
MethodCall* method_call) {
bus_->AssertOnOriginThread();
- base::AutoLock auto_lock(method_is_called_lock_);
response_from_method_ = method_call_callback.Run(method_call);
- method_is_called_ = true;
on_method_is_called_.Signal();
}