| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_WRAPPER_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_WRAPPER_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_WRAPPER_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_WRAPPER_H_ |
| 7 | 7 |
| 8 #include <unordered_set> | 8 #include <unordered_set> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // behavior observers should add/remove themselves to/from the adapter. | 22 // behavior observers should add/remove themselves to/from the adapter. |
| 23 // http://crbug.com/603291 | 23 // http://crbug.com/603291 |
| 24 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterFactoryWrapper { | 24 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterFactoryWrapper { |
| 25 public: | 25 public: |
| 26 typedef base::Callback<void(BluetoothAdapter*)> AcquireAdapterCallback; | 26 typedef base::Callback<void(BluetoothAdapter*)> AcquireAdapterCallback; |
| 27 | 27 |
| 28 ~BluetoothAdapterFactoryWrapper(); | 28 ~BluetoothAdapterFactoryWrapper(); |
| 29 | 29 |
| 30 static BluetoothAdapterFactoryWrapper& Get(); | 30 static BluetoothAdapterFactoryWrapper& Get(); |
| 31 | 31 |
| 32 // Returns true if the platform supports Bluetooth or if | 32 // Returns true if the platform supports Bluetooth Low Energy or if |
| 33 // SetBluetoothAdapterForTesting has been called. | 33 // SetBluetoothAdapterForTesting has been called. |
| 34 bool IsBluetoothAdapterAvailable(); | 34 bool IsLowEnergyAvailable(); |
| 35 | 35 |
| 36 // Adds |observer| to the set of adapter observers. If another observer has | 36 // Adds |observer| to the set of adapter observers. If another observer has |
| 37 // acquired the adapter in the past it adds |observer| as an observer to that | 37 // acquired the adapter in the past it adds |observer| as an observer to that |
| 38 // adapter, otherwise it gets a new adapter and adds |observer| to it. Runs | 38 // adapter, otherwise it gets a new adapter and adds |observer| to it. Runs |
| 39 // |callback| with the adapter |observer| has been added to. | 39 // |callback| with the adapter |observer| has been added to. |
| 40 void AcquireAdapter(BluetoothAdapter::Observer* observer, | 40 void AcquireAdapter(BluetoothAdapter::Observer* observer, |
| 41 const AcquireAdapterCallback& callback); | 41 const AcquireAdapterCallback& callback); |
| 42 // Removes |observer| from the list of adapter observers if |observer| | 42 // Removes |observer| from the list of adapter observers if |observer| |
| 43 // has acquired the adapter in the past. If there are no more observers | 43 // has acquired the adapter in the past. If there are no more observers |
| 44 // it deletes the reference to the adapter. | 44 // it deletes the reference to the adapter. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // Note: This should remain the last member so it'll be destroyed and | 87 // Note: This should remain the last member so it'll be destroyed and |
| 88 // invalidate its weak pointers before any other members are destroyed. | 88 // invalidate its weak pointers before any other members are destroyed. |
| 89 base::WeakPtrFactory<BluetoothAdapterFactoryWrapper> weak_ptr_factory_; | 89 base::WeakPtrFactory<BluetoothAdapterFactoryWrapper> weak_ptr_factory_; |
| 90 | 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterFactoryWrapper); | 91 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterFactoryWrapper); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 } // namespace device | 94 } // namespace device |
| 95 | 95 |
| 96 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_WRAPPER_H_ | 96 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_FACTORY_WRAPPER_H_ |
| OLD | NEW |