| Index: device/bluetooth/bluetooth_adapter.h
|
| diff --git a/device/bluetooth/bluetooth_adapter.h b/device/bluetooth/bluetooth_adapter.h
|
| index 6c70fdf510580a338f7a6f22a4ebf0ed3cb500b0..5184f2953a09bb018f56dc7192422b1156571e89 100644
|
| --- a/device/bluetooth/bluetooth_adapter.h
|
| +++ b/device/bluetooth/bluetooth_adapter.h
|
| @@ -25,6 +25,7 @@ class BluetoothGattDescriptor;
|
| class BluetoothGattService;
|
| class BluetoothSocket;
|
| class BluetoothUUID;
|
| +struct BluetoothAdapterDeleter;
|
|
|
| // BluetoothAdapter represents a local Bluetooth adapter which may be used to
|
| // interact with remote Bluetooth devices. As well as providing support for
|
| @@ -33,7 +34,8 @@ class BluetoothUUID;
|
| // known to the adapter, discovering new devices, and providing notification of
|
| // updates to device information.
|
| class DEVICE_BLUETOOTH_EXPORT BluetoothAdapter
|
| - : public base::RefCounted<BluetoothAdapter> {
|
| + : public base::RefCountedThreadSafe<BluetoothAdapter,
|
| + BluetoothAdapterDeleter> {
|
| public:
|
| // Interface for observing changes from bluetooth adapters.
|
| class Observer {
|
| @@ -334,11 +336,16 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapter
|
| const CreateServiceErrorCallback& error_callback) = 0;
|
|
|
| protected:
|
| - friend class base::RefCounted<BluetoothAdapter>;
|
| + friend class base::RefCountedThreadSafe<BluetoothAdapter,
|
| + BluetoothAdapterDeleter>;
|
| + friend struct BluetoothAdapterDeleter;
|
| friend class BluetoothDiscoverySession;
|
| BluetoothAdapter();
|
| virtual ~BluetoothAdapter();
|
|
|
| + // Called by RefCountedThreadSafeDeleteOnCorrectThread to destroy this.
|
| + virtual void DeleteOnCorrectThread() const = 0;
|
| +
|
| // Internal methods for initiating and terminating device discovery sessions.
|
| // An implementation of BluetoothAdapter keeps an internal reference count to
|
| // make sure that the underlying controller is constantly searching for nearby
|
| @@ -420,6 +427,13 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapter
|
| base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_;
|
| };
|
|
|
| +// Trait for RefCountedThreadSafe that deletes BluetoothAdapter.
|
| +struct BluetoothAdapterDeleter {
|
| + static void Destruct(const BluetoothAdapter* adapter) {
|
| + adapter->DeleteOnCorrectThread();
|
| + }
|
| +};
|
| +
|
| } // namespace device
|
|
|
| #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
|
|
|