summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/bluetooth_device_client.cc
diff options
context:
space:
mode:
authorpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 12:23:04 +0000
committerpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-27 12:23:04 +0000
commitc5fd536cbf85dea5a3bc200a515bdf6cf75b2576 (patch)
tree1f233003e6f5d34428c73b318a89454b7c7ee23b /chromeos/dbus/bluetooth_device_client.cc
parent072414940357abff52558f794af018adfeb6f0d7 (diff)
downloadchromium_src-c5fd536cbf85dea5a3bc200a515bdf6cf75b2576.zip
chromium_src-c5fd536cbf85dea5a3bc200a515bdf6cf75b2576.tar.gz
chromium_src-c5fd536cbf85dea5a3bc200a515bdf6cf75b2576.tar.bz2
Split construction and initialization of DBus clients.
Before, each Client had a Create function which constructed an instance of the client and initialized it (with a dbus::Bus*). To make the Clients separately replaceable in the DBusThreadManager, it's necessary to separate the construction of the Clients from their initialization. This CL, splits each Create function into Create (which only calls the constructor of either the real Impl or the Stub) and Init(dbus::Bus*). This is a pure refactoring. BUG=275286 Review URL: https://chromiumcodereview.appspot.com/23119006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219775 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/bluetooth_device_client.cc')
-rw-r--r--chromeos/dbus/bluetooth_device_client.cc27
1 files changed, 13 insertions, 14 deletions
diff --git a/chromeos/dbus/bluetooth_device_client.cc b/chromeos/dbus/bluetooth_device_client.cc
index 62fbab8..605872c 100644
--- a/chromeos/dbus/bluetooth_device_client.cc
+++ b/chromeos/dbus/bluetooth_device_client.cc
@@ -53,16 +53,7 @@ class BluetoothDeviceClientImpl
: public BluetoothDeviceClient,
public dbus::ObjectManager::Interface {
public:
- explicit BluetoothDeviceClientImpl(dbus::Bus* bus)
- : bus_(bus),
- weak_ptr_factory_(this) {
- object_manager_ = bus_->GetObjectManager(
- bluetooth_object_manager::kBluetoothObjectManagerServiceName,
- dbus::ObjectPath(
- bluetooth_object_manager::kBluetoothObjectManagerServicePath));
- object_manager_->RegisterInterface(
- bluetooth_device::kBluetoothDeviceInterface, this);
- }
+ BluetoothDeviceClientImpl() : weak_ptr_factory_(this) {}
virtual ~BluetoothDeviceClientImpl() {
object_manager_->UnregisterInterface(
@@ -277,6 +268,16 @@ class BluetoothDeviceClientImpl
weak_ptr_factory_.GetWeakPtr(), error_callback));
}
+ protected:
+ virtual void Init(dbus::Bus* bus) OVERRIDE {
+ object_manager_ = bus->GetObjectManager(
+ bluetooth_object_manager::kBluetoothObjectManagerServiceName,
+ dbus::ObjectPath(
+ bluetooth_object_manager::kBluetoothObjectManagerServicePath));
+ object_manager_->RegisterInterface(
+ bluetooth_device::kBluetoothDeviceInterface, this);
+ }
+
private:
// Called by dbus::ObjectManager when an object with the device interface
// is created. Informs observers.
@@ -327,7 +328,6 @@ class BluetoothDeviceClientImpl
error_callback.Run(error_name, error_message);
}
- dbus::Bus* bus_;
dbus::ObjectManager* object_manager_;
// List of observers interested in event notifications from us.
@@ -349,10 +349,9 @@ BluetoothDeviceClient::~BluetoothDeviceClient() {
}
BluetoothDeviceClient* BluetoothDeviceClient::Create(
- DBusClientImplementationType type,
- dbus::Bus* bus) {
+ DBusClientImplementationType type) {
if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
- return new BluetoothDeviceClientImpl(bus);
+ return new BluetoothDeviceClientImpl();
DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type);
return new FakeBluetoothDeviceClient();
}