Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2074)

Unified Diff: dbus/bus.cc

Issue 12224139: Supporting callback for Disconnected signal. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing and addressing comment Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dbus/bus.cc
diff --git a/dbus/bus.cc b/dbus/bus.cc
index 1c258d20b19b8949c58178f77253962b3ff74c27..cb7f145c5a75fa7c3d45015177faae93fb21b661 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::CloseConnection() {
+ // dbus_connection_close is blocking call.
+ AssertOnDBusThread();
+
+ if (connection_type_ == PRIVATE)
satorux1 2013/02/15 03:55:20 why do we need to check the type?
Seigo Nonaka 2013/02/15 04:18:36 Because dbus_connection_close is only for private
satorux1 2013/02/15 04:25:11 Then let's rename this function to ClosePrivateCon
Seigo Nonaka 2013/02/15 04:36:10 Done.
+ dbus_connection_close(connection_);
+}
+
void Bus::ShutdownAndBlock() {
AssertOnDBusThread();
@@ -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));
« dbus/bus.h ('K') | « dbus/bus.h ('k') | dbus/end_to_end_async_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698