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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 connection_ = dbus_bus_get_private(dbus_bus_type, error.get()); | 301 connection_ = dbus_bus_get_private(dbus_bus_type, error.get()); |
302 } else { | 302 } else { |
303 connection_ = dbus_bus_get(dbus_bus_type, error.get()); | 303 connection_ = dbus_bus_get(dbus_bus_type, error.get()); |
304 } | 304 } |
305 } | 305 } |
306 if (!connection_) { | 306 if (!connection_) { |
307 LOG(ERROR) << "Failed to connect to the bus: " | 307 LOG(ERROR) << "Failed to connect to the bus: " |
308 << (error.is_set() ? error.message() : ""); | 308 << (error.is_set() ? error.message() : ""); |
309 return false; | 309 return false; |
310 } | 310 } |
| 311 |
| 312 if (bus_type_ == CUSTOM_ADDRESS) { |
| 313 // We should call dbus_bus_register here, otherwise unique name can not be |
| 314 // acquired. According to dbus specification, it is responsible to call |
| 315 // org.freedesktop.DBus.Hello method at the beging of bus connection to |
| 316 // acquire unique name. In the case of dbus_bus_get, dbus_bus_register is |
| 317 // called internally. |
| 318 if (!dbus_bus_register(connection_, error.get())) { |
| 319 LOG(ERROR) << "Failed to register the bus component: " |
| 320 << (error.is_set() ? error.message() : ""); |
| 321 return false; |
| 322 } |
| 323 } |
311 // We shouldn't exit on the disconnected signal. | 324 // We shouldn't exit on the disconnected signal. |
312 dbus_connection_set_exit_on_disconnect(connection_, false); | 325 dbus_connection_set_exit_on_disconnect(connection_, false); |
313 | 326 |
314 return true; | 327 return true; |
315 } | 328 } |
316 | 329 |
317 void Bus::ShutdownAndBlock() { | 330 void Bus::ShutdownAndBlock() { |
318 AssertOnDBusThread(); | 331 AssertOnDBusThread(); |
319 | 332 |
320 // Unregister the exported objects. | 333 // Unregister the exported objects. |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 } | 843 } |
831 | 844 |
832 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, | 845 void Bus::OnDispatchStatusChangedThunk(DBusConnection* connection, |
833 DBusDispatchStatus status, | 846 DBusDispatchStatus status, |
834 void* data) { | 847 void* data) { |
835 Bus* self = static_cast<Bus*>(data); | 848 Bus* self = static_cast<Bus*>(data); |
836 self->OnDispatchStatusChanged(connection, status); | 849 self->OnDispatchStatusChanged(connection, status); |
837 } | 850 } |
838 | 851 |
839 } // namespace dbus | 852 } // namespace dbus |
OLD | NEW |