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

Side by Side Diff: dbus/bus.cc

Issue 9691025: dbus: allow unregistering of exported objects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update doc from nit 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dbus/bus.h ('k') | dbus/bus_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // TODO(satorux): 5 // TODO(satorux):
6 // - Handle "disconnected" signal. 6 // - Handle "disconnected" signal.
7 7
8 #include "dbus/bus.h" 8 #include "dbus/bus.h"
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return iter->second; 243 return iter->second;
244 } 244 }
245 245
246 scoped_refptr<ExportedObject> exported_object = 246 scoped_refptr<ExportedObject> exported_object =
247 new ExportedObject(this, object_path); 247 new ExportedObject(this, object_path);
248 exported_object_table_[object_path] = exported_object; 248 exported_object_table_[object_path] = exported_object;
249 249
250 return exported_object.get(); 250 return exported_object.get();
251 } 251 }
252 252
253 void Bus::UnregisterExportedObject(const ObjectPath& object_path) {
254 AssertOnOriginThread();
255
256 // Remove the registered object from the table first, to allow a new
257 // GetExportedObject() call to return a new object, rather than this one.
258 ExportedObjectTable::iterator iter = exported_object_table_.find(object_path);
259 if (iter == exported_object_table_.end())
260 return;
261
262 scoped_refptr<ExportedObject> exported_object = iter->second;
263 exported_object_table_.erase(iter);
264
265 // Post the task to perform the final unregistration to the D-Bus thread.
266 // Since the registration also happens on the D-Bus thread in
267 // TryRegisterObjectPath(), and the message loop proxy we post to is a
268 // MessageLoopProxy which inherits from SequencedTaskRunner, there is a
269 // guarantee that this will happen before any future registration call.
270 PostTaskToDBusThread(FROM_HERE, base::Bind(
271 &Bus::UnregisterExportedObjectInternal,
272 this, exported_object));
273 }
274
275 void Bus::UnregisterExportedObjectInternal(
276 scoped_refptr<dbus::ExportedObject> exported_object) {
277 AssertOnDBusThread();
278
279 exported_object->Unregister();
280 }
281
253 bool Bus::Connect() { 282 bool Bus::Connect() {
254 // dbus_bus_get_private() and dbus_bus_get() are blocking calls. 283 // dbus_bus_get_private() and dbus_bus_get() are blocking calls.
255 AssertOnDBusThread(); 284 AssertOnDBusThread();
256 285
257 // Check if it's already initialized. 286 // Check if it's already initialized.
258 if (connection_) 287 if (connection_)
259 return true; 288 return true;
260 289
261 ScopedDBusError error; 290 ScopedDBusError error;
262 const DBusBusType dbus_bus_type = static_cast<DBusBusType>(bus_type_); 291 const DBusBusType dbus_bus_type = static_cast<DBusBusType>(bus_type_);
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 } 818 }
790 819
791 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, 820 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection,
792 DBusDispatchStatus status, 821 DBusDispatchStatus status,
793 void* data) { 822 void* data) {
794 Bus* self = static_cast<Bus*>(data); 823 Bus* self = static_cast<Bus*>(data);
795 return self->OnDispatchStatusChanged(connection, status); 824 return self->OnDispatchStatusChanged(connection, status);
796 } 825 }
797 826
798 } // namespace dbus 827 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/bus.h ('k') | dbus/bus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698