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 PostTaskToDBusThread(FROM_HERE, base::Bind( |
| 257 &Bus::UnregisterExportedObjectInternal, |
| 258 this, object_path)); |
| 259 } |
| 260 |
| 261 void Bus::UnregisterExportedObjectInternal(const ObjectPath& object_path) { |
| 262 AssertOnDBusThread(); |
| 263 |
| 264 // Make sure the requested object exists. |
| 265 ExportedObjectTable::iterator iter = exported_object_table_.find(object_path); |
| 266 if (iter == exported_object_table_.end()) |
| 267 return; |
| 268 |
| 269 iter->second->Unregister(); |
| 270 exported_object_table_.erase(iter); |
| 271 } |
| 272 |
253 bool Bus::Connect() { | 273 bool Bus::Connect() { |
254 // dbus_bus_get_private() and dbus_bus_get() are blocking calls. | 274 // dbus_bus_get_private() and dbus_bus_get() are blocking calls. |
255 AssertOnDBusThread(); | 275 AssertOnDBusThread(); |
256 | 276 |
257 // Check if it's already initialized. | 277 // Check if it's already initialized. |
258 if (connection_) | 278 if (connection_) |
259 return true; | 279 return true; |
260 | 280 |
261 ScopedDBusError error; | 281 ScopedDBusError error; |
262 const DBusBusType dbus_bus_type = static_cast<DBusBusType>(bus_type_); | 282 const DBusBusType dbus_bus_type = static_cast<DBusBusType>(bus_type_); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 } | 809 } |
790 | 810 |
791 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, | 811 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, |
792 DBusDispatchStatus status, | 812 DBusDispatchStatus status, |
793 void* data) { | 813 void* data) { |
794 Bus* self = static_cast<Bus*>(data); | 814 Bus* self = static_cast<Bus*>(data); |
795 return self->OnDispatchStatusChanged(connection, status); | 815 return self->OnDispatchStatusChanged(connection, status); |
796 } | 816 } |
797 | 817 |
798 } // namespace dbus | 818 } // namespace dbus |
OLD | NEW |