summaryrefslogtreecommitdiffstats
path: root/dbus/bus.cc
diff options
context:
space:
mode:
authornona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-15 16:44:40 +0000
committernona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-15 16:44:40 +0000
commitea5451957df86623f9dd52ad2dd2c12c5ecd70a6 (patch)
tree8fa3aa300a73b7fd2372f40429ebdc87bcd198a1 /dbus/bus.cc
parentce88a911017e862c1623c481e41e810330112647 (diff)
downloadchromium_src-ea5451957df86623f9dd52ad2dd2c12c5ecd70a6.zip
chromium_src-ea5451957df86623f9dd52ad2dd2c12c5ecd70a6.tar.gz
chromium_src-ea5451957df86623f9dd52ad2dd2c12c5ecd70a6.tar.bz2
Supporting callback for Disconnected signal.
If the connection with dbus-daemon is closed, callback function set with SetDisconnectedCallback will be called. BUG=None TEST=ran dbus_unittests Review URL: https://chromiumcodereview.appspot.com/12224139 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/bus.cc')
-rw-r--r--dbus/bus.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/dbus/bus.cc b/dbus/bus.cc
index 1c258d2..30089ab 100644
--- a/dbus/bus.cc
+++ b/dbus/bus.cc
@@ -189,7 +189,8 @@ Bus::Bus(const Options& options)
shutdown_completed_(false),
num_pending_watches_(0),
num_pending_timeouts_(0),
- address_(options.address) {
+ address_(options.address),
+ on_disconnected_closure_(options.disconnected_callback) {
// This is safe to call multiple times.
dbus_threads_init_default();
// The origin message loop is unnecessary if the client uses synchronous
@@ -373,6 +374,14 @@ bool Bus::Connect() {
return true;
}
+void Bus::ClosePrivateConnection() {
+ // dbus_connection_close is blocking call.
+ AssertOnDBusThread();
+ DCHECK_EQ(PRIVATE, connection_type_)
+ << "non-private connection should not be closed";
+ dbus_connection_close(connection_);
+}
+
void Bus::ShutdownAndBlock() {
AssertOnDBusThread();
@@ -418,7 +427,7 @@ void Bus::ShutdownAndBlock() {
RemoveMatch(kDisconnectedMatchRule, error.get());
if (connection_type_ == PRIVATE)
- dbus_connection_close(connection_);
+ ClosePrivateConnection();
// dbus_connection_close() won't unref.
dbus_connection_unref(connection_);
}
@@ -871,6 +880,9 @@ void Bus::OnDispatchStatusChanged(DBusConnection* connection,
void Bus::OnConnectionDisconnected(DBusConnection* connection) {
AssertOnDBusThread();
+ if (!on_disconnected_closure_.is_null())
+ PostTaskToOriginThread(FROM_HERE, on_disconnected_closure_);
+
if (!connection)
return;
DCHECK(!dbus_connection_get_is_connected(connection));