diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 06:56:23 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-02 06:56:23 +0000 |
commit | e20d39fe8164f6633d8224030133a1c6ad18a289 (patch) | |
tree | d5cd7f78a9307a6eba086c5eedc7dd7fdcea4e82 /dbus/test_service.cc | |
parent | 769b082f1fac6e60249c2e6f45bd2432390d7c5a (diff) | |
download | chromium_src-e20d39fe8164f6633d8224030133a1c6ad18a289.zip chromium_src-e20d39fe8164f6633d8224030133a1c6ad18a289.tar.gz chromium_src-e20d39fe8164f6633d8224030133a1c6ad18a289.tar.bz2 |
Add Bus::ShutdownOnDBusThreadAndBlock() and remove bus::Shutdown()
This function is intended to use at the the very end of the browser shutdown,
where it it makes more sense to shut down the bus synchronously, than trying
to make it asynchronous.
Remove Bus::Shutdown() as we are unlikely to need it for the production code.
BUG=chromium:90036
TEST=dbus_unittests
Review URL: http://codereview.chromium.org/7830009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/test_service.cc')
-rw-r--r-- | dbus/test_service.cc | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/dbus/test_service.cc b/dbus/test_service.cc index acab607..1b8b9bf 100644 --- a/dbus/test_service.cc +++ b/dbus/test_service.cc @@ -26,7 +26,6 @@ TestService::Options::~Options() { TestService::TestService(const Options& options) : base::Thread("TestService"), dbus_thread_(options.dbus_thread), - on_shutdown_(false /* manual_reset */, false /* initially_signaled */), on_all_methods_exported_(false, false), num_exported_methods_(0) { } @@ -48,24 +47,24 @@ bool TestService::WaitUntilServiceIsStarted() { return on_all_methods_exported_.TimedWait(timeout); } -void TestService::Shutdown() { +void TestService::ShutdownAndBlock() { message_loop()->PostTask( FROM_HERE, - base::Bind(&TestService::ShutdownInternal, + base::Bind(&TestService::ShutdownAndBlockInternal, base::Unretained(this))); } -bool TestService::WaitUntilServiceIsShutdown() { - const base::TimeDelta timeout( - base::TimeDelta::FromMilliseconds( - TestTimeouts::action_max_timeout_ms())); - return on_shutdown_.TimedWait(timeout); -} - bool TestService::HasDBusThread() { return bus_->HasDBusThread(); } +void TestService::ShutdownAndBlockInternal() { + if (HasDBusThread()) + bus_->ShutdownOnDBusThreadAndBlock(); + else + bus_->ShutdownAndBlock(); +} + void TestService::SendTestSignal(const std::string& message) { message_loop()->PostTask( FROM_HERE, @@ -81,11 +80,6 @@ void TestService::SendTestSignalInternal(const std::string& message) { exported_object_->SendSignal(&signal); } -void TestService::ShutdownInternal() { - bus_->Shutdown(base::Bind(&TestService::OnShutdown, - base::Unretained(this))); -} - void TestService::OnExported(const std::string& interface_name, const std::string& method_name, bool success) { @@ -102,10 +96,6 @@ void TestService::OnExported(const std::string& interface_name, on_all_methods_exported_.Signal(); } -void TestService::OnShutdown() { - on_shutdown_.Signal(); -} - void TestService::Run(MessageLoop* message_loop) { Bus::Options bus_options; bus_options.bus_type = Bus::SESSION; |