Make DBus a singleton.
All the proxies need dbus to initialize, so we are passing dbus around,
to make it easier to compile dbus conditionally, this patch makes it a
singleton so that the proxies can get dbus on their own.
Test: mma
Bug: 28800946
Change-Id: Idf062c843aa34a431c2201bae5b895dc1d0ea787
diff --git a/libcros_proxy.cc b/libcros_proxy.cc
index 689ed39..3aa87cb 100644
--- a/libcros_proxy.cc
+++ b/libcros_proxy.cc
@@ -16,6 +16,8 @@
#include "update_engine/libcros_proxy.h"
+#include "update_engine/dbus_connection.h"
+
using org::chromium::LibCrosServiceInterfaceProxy;
using org::chromium::LibCrosServiceInterfaceProxyInterface;
using org::chromium::UpdateEngineLibcrosProxyResolvedInterfaceProxy;
@@ -36,13 +38,13 @@
ue_proxy_resolved_interface_(std::move(ue_proxy_resolved_interface)) {
}
-LibCrosProxy::LibCrosProxy(const scoped_refptr<dbus::Bus>& bus)
- : service_interface_proxy_(
- new LibCrosServiceInterfaceProxy(bus, kLibCrosServiceName)),
- ue_proxy_resolved_interface_(
- new UpdateEngineLibcrosProxyResolvedInterfaceProxy(
- bus,
- kLibCrosServiceName)) {
+LibCrosProxy::LibCrosProxy() {
+ const scoped_refptr<dbus::Bus>& bus = DBusConnection::Get()->GetDBus();
+ service_interface_proxy_.reset(
+ new LibCrosServiceInterfaceProxy(bus, kLibCrosServiceName));
+ ue_proxy_resolved_interface_.reset(
+ new UpdateEngineLibcrosProxyResolvedInterfaceProxy(bus,
+ kLibCrosServiceName));
}
LibCrosServiceInterfaceProxyInterface* LibCrosProxy::service_interface_proxy() {