diff options
author | bryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-07 07:02:43 +0000 |
---|---|---|
committer | bryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-07 07:02:43 +0000 |
commit | aa92aca78bb3fa8c98335daa87db2c7dee3d3c46 (patch) | |
tree | dae251dd872972efb5cdabff7883d7ca6a5f65a2 /chrome/browser/chromeos/bluetooth | |
parent | 0e9f3e321842c50f7011cca1b40db01d5e798889 (diff) | |
download | chromium_src-aa92aca78bb3fa8c98335daa87db2c7dee3d3c46.zip chromium_src-aa92aca78bb3fa8c98335daa87db2c7dee3d3c46.tar.gz chromium_src-aa92aca78bb3fa8c98335daa87db2c7dee3d3c46.tar.bz2 |
Clean up WeakPtrFactory usage.
TEST=none
BUG=none
R=satorux@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10910115
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/bluetooth')
4 files changed, 14 insertions, 14 deletions
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc b/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc index 005528e..bd0cada 100644 --- a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc +++ b/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc @@ -30,10 +30,10 @@ base::LazyInstance<base::WeakPtr<chromeos::BluetoothAdapter> >::Leaky namespace chromeos { -BluetoothAdapter::BluetoothAdapter() : weak_ptr_factory_(this), - track_default_(false), +BluetoothAdapter::BluetoothAdapter() : track_default_(false), powered_(false), - discovering_(false) { + discovering_(false), + weak_ptr_factory_(this) { DBusThreadManager::Get()->GetBluetoothManagerClient()-> AddObserver(this); DBusThreadManager::Get()->GetBluetoothAdapterClient()-> diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.h b/chrome/browser/chromeos/bluetooth/bluetooth_adapter.h index 9204282..4ee79d1 100644 --- a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.h +++ b/chrome/browser/chromeos/bluetooth/bluetooth_adapter.h @@ -306,10 +306,6 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>, // List of observers interested in event notifications from us. ObserverList<BluetoothAdapter::Observer> observers_; - // Weak pointer factory for generating 'this' pointers that might live longer - // than we do. - base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; - // Object path of adapter for this instance, this is fixed at creation time // unless |track_default_| is true in which case we update it to always // point at the default adapter. @@ -334,6 +330,10 @@ class BluetoothAdapter : public base::RefCounted<BluetoothAdapter>, typedef std::map<const std::string, BluetoothDevice*> DevicesMap; DevicesMap devices_; + // 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<BluetoothAdapter> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(BluetoothAdapter); }; diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc index 47c1ae9..ba19dc5 100644 --- a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc +++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc @@ -38,14 +38,14 @@ namespace chromeos { BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter) - : weak_ptr_factory_(this), - adapter_(adapter), + : adapter_(adapter), bluetooth_class_(0), visible_(false), bonded_(false), connected_(false), pairing_delegate_(NULL), - connecting_applications_counter_(0) { + connecting_applications_counter_(0), + weak_ptr_factory_(this) { } BluetoothDevice::~BluetoothDevice() { diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.h b/chrome/browser/chromeos/bluetooth/bluetooth_device.h index 0064f48..aa2fdfc 100644 --- a/chrome/browser/chromeos/bluetooth/bluetooth_device.h +++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.h @@ -557,10 +557,6 @@ class BluetoothDevice : public BluetoothDeviceClient::Observer, // Creates a new BluetoothDevice object bound to the adapter |adapter|. static BluetoothDevice* Create(BluetoothAdapter* adapter); - // Weak pointer factory for generating 'this' pointers that might live longer - // than we do. - base::WeakPtrFactory<BluetoothDevice> weak_ptr_factory_; - // The adapter that owns this device instance. BluetoothAdapter* adapter_; @@ -606,6 +602,10 @@ class BluetoothDevice : public BluetoothDeviceClient::Observer, // Used to keep track of pending application connection requests. int connecting_applications_counter_; + // 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<BluetoothDevice> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(BluetoothDevice); }; |