summaryrefslogtreecommitdiffstats
path: root/dbus/test_service.h
diff options
context:
space:
mode:
authorharuki@chromium.org <haruki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 11:02:59 +0000
committerharuki@chromium.org <haruki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 11:02:59 +0000
commit6d36c0cadfc825db5336a04c1c0778ebe2652a92 (patch)
tree451eecc45061e3bc58c02deb20032a37d49c733f /dbus/test_service.h
parent8a2e513493bd5b0d2eb8e068975efc2e91fb5250 (diff)
downloadchromium_src-6d36c0cadfc825db5336a04c1c0778ebe2652a92.zip
chromium_src-6d36c0cadfc825db5336a04c1c0778ebe2652a92.tar.gz
chromium_src-6d36c0cadfc825db5336a04c1c0778ebe2652a92.tar.bz2
Make SignalSenderVerificationTest more robust
Add more assertions and a callback to check the result of RequestOwnership. Original test can hang when test_service2_ tries to acquire the ownership before D-Bus recognizes test_service_'s disconnection. In that situation, test_service2_ cannot own the name and cannot send a message. BUG=158689 TEST=unittests Review URL: https://chromiumcodereview.appspot.com/11358111 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167649 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/test_service.h')
-rw-r--r--dbus/test_service.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/dbus/test_service.h b/dbus/test_service.h
index 17f27ca..30f8216 100644
--- a/dbus/test_service.h
+++ b/dbus/test_service.h
@@ -66,7 +66,12 @@ class TestService : public base::Thread {
void SendTestSignalFromRoot(const std::string& message);
// Request the ownership of a well-known name "TestService".
- void RequestOwnership();
+ // |callback| will be called with the result when an ownership request is
+ // completed.
+ void RequestOwnership(base::Callback<void(bool)> callback);
+
+ // Returns whether this instance has the name ownership or not.
+ bool has_ownership() const { return has_ownership_; }
private:
// Helper function for SendTestSignal().
@@ -79,7 +84,12 @@ class TestService : public base::Thread {
void ShutdownAndBlockInternal();
// Called when an ownership request is completed.
- void OnOwnership(const std::string& service_name,
+ // |callback| is the callback to be called with the result. |service_name| is
+ // the requested well-known bus name. |callback| and |service_name| are bound
+ // when the service requests the ownership. |success| is the result of the
+ // completed request, and is propagated to |callback|.
+ void OnOwnership(base::Callback<void(bool)> callback,
+ const std::string& service_name,
bool success);
// Called when a method is exported.
@@ -131,13 +141,16 @@ class TestService : public base::Thread {
void SendPropertyChangedSignalInternal(const std::string& name);
// Helper function for RequestOwnership().
- void RequestOwnershipInternal();
+ void RequestOwnershipInternal(base::Callback<void(bool)> callback);
scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_;
base::WaitableEvent on_all_methods_exported_;
// The number of methods actually exported.
int num_exported_methods_;
+ // True iff this instance has successfully acquired the name ownership.
+ bool has_ownership_;
+
scoped_refptr<Bus> bus_;
ExportedObject* exported_object_;
};