aboutsummaryrefslogtreecommitdiff
path: root/chromeos
diff options
context:
space:
mode:
authorPeter Qiu <zqiu@chromium.org>2015-08-07 16:24:46 -0700
committerBertrand SIMONNET <bsimonnet@google.com>2015-08-12 10:57:55 -0700
commitd131ec9eec54994ce9b456f43febe41b3a6974e7 (patch)
tree89d70cc81d7c28f85752b612d503513e5d869f6e /chromeos
parentd145d0a667c8ccd56378f1b78176e04f4a5b03df (diff)
downloadlibbrillo-d131ec9eec54994ce9b456f43febe41b3a6974e7.tar.gz
libchromeos: dbus: unregister DBus object synchronously
When DBus object is unregistered explicitly, it allows its path to be reused. BUG=chromium:518026 TEST=emerge-$BOARD libchromeos shill TEST=Verify using shill with chromeos dbus Reviewed-on: https://chromium-review.googlesource.com/291841 Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Tested-by: Zeping Qiu <zqiu@chromium.org> Commit-Queue: Zeping Qiu <zqiu@chromium.org> (cherry-picked from https://chromium.googlesource.com/chromiumos/platform2 at 5688fbaf4aeb195c6915d3f362b888e549b7a010) Change-Id: I77d88089b687df85afd78ebe0178040f24be8a31
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/dbus_object.cc15
-rw-r--r--chromeos/dbus/dbus_object.h7
2 files changed, 22 insertions, 0 deletions
diff --git a/chromeos/dbus/dbus_object.cc b/chromeos/dbus/dbus_object.cc
index eaed1b9..16539e2 100644
--- a/chromeos/dbus/dbus_object.cc
+++ b/chromeos/dbus/dbus_object.cc
@@ -251,6 +251,21 @@ void DBusObject::RegisterAndBlock() {
}
}
+void DBusObject::UnregisterAsync() {
+ VLOG(1) << "Unregistering D-Bus object '" << object_path_.value() << "'.";
+ CHECK(exported_object_ != nullptr) << "Object not registered.";
+
+ // This will unregister the object path from the bus.
+ exported_object_->Unregister();
+ // This will remove |exported_object_| from bus's object table. This function
+ // will also post a task to unregister |exported_object_| (same as the call
+ // above), which will be a no-op since it is already done by then.
+ // By doing both in here, the object path is guarantee to be reusable upon
+ // return from this function.
+ bus_->UnregisterExportedObject(object_path_);
+ exported_object_ = nullptr;
+}
+
bool DBusObject::SendSignal(dbus::Signal* signal) {
if (exported_object_) {
exported_object_->SendSignal(signal);
diff --git a/chromeos/dbus/dbus_object.h b/chromeos/dbus/dbus_object.h
index 441df5b..10894e6 100644
--- a/chromeos/dbus/dbus_object.h
+++ b/chromeos/dbus/dbus_object.h
@@ -534,6 +534,13 @@ class CHROMEOS_EXPORT DBusObject {
// will block until the object and all of its interfaces are registered.
virtual void RegisterAndBlock();
+ // Unregister the object instance with D-Bus. This will unregister the
+ // |exported_object_| and its path from the bus. The destruction of
+ // |exported_object_| will be deferred in an async task posted by the bus.
+ // It is guarantee that upon return from this call a new DBusObject with the
+ // same object path can be created/registered.
+ virtual void UnregisterAsync();
+
// Returns the ExportedObjectManager proxy, if any. If DBusObject has been
// constructed without an object manager, this method returns an empty
// smart pointer (containing nullptr).