| Index: device/bluetooth/bluetooth_adapter_factory.cc
|
| diff --git a/device/bluetooth/bluetooth_adapter_factory.cc b/device/bluetooth/bluetooth_adapter_factory.cc
|
| index ed64ecd2ee670bd91ed4328924455edf5de60f8b..3358c38bdbf4f3356507acba6ea2e24aa8580fb0 100644
|
| --- a/device/bluetooth/bluetooth_adapter_factory.cc
|
| +++ b/device/bluetooth/bluetooth_adapter_factory.cc
|
| @@ -21,6 +21,9 @@ namespace device {
|
|
|
| namespace {
|
|
|
| +static base::LazyInstance<BluetoothAdapterFactory>::Leaky g_singleton =
|
| + LAZY_INSTANCE_INITIALIZER;
|
| +
|
| // Shared default adapter instance. We don't want to keep this class around
|
| // if nobody is using it, so use a WeakPtr and create the object when needed.
|
| // Since Google C++ Style (and clang's static analyzer) forbids us having
|
| @@ -53,6 +56,13 @@ void RunAdapterCallbacks() {
|
|
|
| } // namespace
|
|
|
| +BluetoothAdapterFactory::~BluetoothAdapterFactory() {}
|
| +
|
| +// static
|
| +BluetoothAdapterFactory& BluetoothAdapterFactory::Get() {
|
| + return g_singleton.Get();
|
| +}
|
| +
|
| // static
|
| bool BluetoothAdapterFactory::IsBluetoothAdapterAvailable() {
|
| // SetAdapterForTesting() may be used to provide a test or mock adapter
|
| @@ -67,8 +77,11 @@ bool BluetoothAdapterFactory::IsBluetoothAdapterAvailable() {
|
| #endif
|
| }
|
|
|
| -// static
|
| bool BluetoothAdapterFactory::IsLowEnergyAvailable() {
|
| + if (le_available_for_testing_) {
|
| + return le_available_for_testing_.value();
|
| + }
|
| +
|
| DCHECK(IsBluetoothAdapterAvailable());
|
|
|
| // SetAdapterForTesting() may be used to provide a test or mock adapter
|
| @@ -131,4 +144,10 @@ bool BluetoothAdapterFactory::HasSharedInstanceForTesting() {
|
| return default_adapter.Get() != nullptr;
|
| }
|
|
|
| +void BluetoothAdapterFactory::SetLowEnergyAvailableForTesting(bool available) {
|
| + le_available_for_testing_ = base::make_optional(available);
|
| +}
|
| +
|
| +BluetoothAdapterFactory::BluetoothAdapterFactory() {}
|
| +
|
| } // namespace device
|
|
|