From 926957b72bee0ee2b268d946bc0ae25047e92539 Mon Sep 17 00:00:00 2001 From: "gdk@chromium.org" Date: Fri, 7 Sep 2012 05:34:16 +0000 Subject: Cleaning up weak_ptr_factory destruction order. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10917115 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155319 0039d316-1c4b-4281-b951-d872f2087c98 --- chromeos/dbus/bluetooth_device_client.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'chromeos/dbus/bluetooth_device_client.cc') diff --git a/chromeos/dbus/bluetooth_device_client.cc b/chromeos/dbus/bluetooth_device_client.cc index 10bda3f..df237e8 100644 --- a/chromeos/dbus/bluetooth_device_client.cc +++ b/chromeos/dbus/bluetooth_device_client.cc @@ -55,8 +55,8 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient, public: BluetoothDeviceClientImpl(dbus::Bus* bus, BluetoothAdapterClient* adapter_client) - : weak_ptr_factory_(this), - bus_(bus) { + : bus_(bus), + weak_ptr_factory_(this) { DVLOG(1) << "Creating BluetoothDeviceClientImpl"; DCHECK(adapter_client); @@ -449,15 +449,17 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient, callback.Run(object_path, response); } - // Weak pointer factory for generating 'this' pointers that might live longer - // than we do. - base::WeakPtrFactory weak_ptr_factory_; - dbus::Bus* bus_; // List of observers interested in event notifications from us. ObserverList observers_; + // Weak pointer factory for generating 'this' pointers that might live longer + // than we do. + // Note: This should remain the last member so it'll be destroyed and + // invalidate its weak pointers before any other members are destroyed. + base::WeakPtrFactory weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceClientImpl); }; -- cgit v1.1