OLD | NEW |
---|---|
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 Loading... | |
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, and the message | |
267 // loop proxy is a SequencedTaskRunner, there is a guarantee that this will | |
satorux1
2012/03/13 20:15:33
I was confused at first. might want to add somethi
keybuk
2012/03/13 20:25:01
Done.
| |
268 // happen before any future registration call. | |
269 PostTaskToDBusThread(FROM_HERE, base::Bind( | |
270 &Bus::UnregisterExportedObjectInternal, | |
271 this, exported_object)); | |
272 } | |
273 | |
274 void Bus::UnregisterExportedObjectInternal( | |
275 scoped_refptr<dbus::ExportedObject> exported_object) { | |
276 AssertOnDBusThread(); | |
277 | |
278 exported_object->Unregister(); | |
279 } | |
280 | |
253 bool Bus::Connect() { | 281 bool Bus::Connect() { |
254 // dbus_bus_get_private() and dbus_bus_get() are blocking calls. | 282 // dbus_bus_get_private() and dbus_bus_get() are blocking calls. |
255 AssertOnDBusThread(); | 283 AssertOnDBusThread(); |
256 | 284 |
257 // Check if it's already initialized. | 285 // Check if it's already initialized. |
258 if (connection_) | 286 if (connection_) |
259 return true; | 287 return true; |
260 | 288 |
261 ScopedDBusError error; | 289 ScopedDBusError error; |
262 const DBusBusType dbus_bus_type = static_cast<DBusBusType>(bus_type_); | 290 const DBusBusType dbus_bus_type = static_cast<DBusBusType>(bus_type_); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
789 } | 817 } |
790 | 818 |
791 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, | 819 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, |
792 DBusDispatchStatus status, | 820 DBusDispatchStatus status, |
793 void* data) { | 821 void* data) { |
794 Bus* self = static_cast<Bus*>(data); | 822 Bus* self = static_cast<Bus*>(data); |
795 return self->OnDispatchStatusChanged(connection, status); | 823 return self->OnDispatchStatusChanged(connection, status); |
796 } | 824 } |
797 | 825 |
798 } // namespace dbus | 826 } // namespace dbus |
OLD | NEW |