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

Unified Diff: dbus/bus.cc

Issue 9691025: dbus: allow unregistering of exported objects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make the method block, and add a unit test Created 8 years, 9 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
« dbus/bus.h ('K') | « dbus/bus.h ('k') | dbus/bus_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/bus.cc
diff --git a/dbus/bus.cc b/dbus/bus.cc
index 9d4a43638495a361f54d466e5890424285e2b4e6..727f47dbb218b1cef8ad5c543efb05d9b9970905 100644
--- a/dbus/bus.cc
+++ b/dbus/bus.cc
@@ -12,6 +12,7 @@
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "base/stl_util.h"
+#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "base/time.h"
@@ -250,6 +251,34 @@ ExportedObject* Bus::GetExportedObject(const ObjectPath& object_path) {
return exported_object.get();
}
+void Bus::UnregisterExportedObject(const ObjectPath& object_path) {
+ AssertOnOriginThread();
+
+ base::WaitableEvent completion(false, false);
+
+ PostTaskToDBusThread(FROM_HERE, base::Bind(
+ &Bus::UnregisterExportedObjectInternal,
+ this, object_path, &completion));
+
+ completion.Wait();
+}
+
+void Bus::UnregisterExportedObjectInternal(const ObjectPath& object_path,
+ base::WaitableEvent* completion) {
+ DCHECK(completion);
+ AssertOnDBusThread();
+
+ // Make sure the requested object exists.
+ ExportedObjectTable::iterator iter = exported_object_table_.find(object_path);
+ if (iter == exported_object_table_.end())
+ return;
+
+ iter->second->Unregister();
+ exported_object_table_.erase(iter);
+
+ completion->Signal();
+}
+
bool Bus::Connect() {
// dbus_bus_get_private() and dbus_bus_get() are blocking calls.
AssertOnDBusThread();
« dbus/bus.h ('K') | « dbus/bus.h ('k') | dbus/bus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698