#include "device/bluetooth/bluetooth_adapter_factory.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/no_destructor.h"
#include "build/build_config.h"
#include "device/bluetooth/bluetooth_adapter.h"
#if BUILDFLAG(IS_APPLE)
#include "base/mac/mac_util.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "device/bluetooth/bluetooth_adapter_win.h"
#endif
namespace device {
BluetoothAdapterFactory::BluetoothAdapterFactory() = default;
BluetoothAdapterFactory::~BluetoothAdapterFactory() = default;
BluetoothAdapterFactory* BluetoothAdapterFactory::Get() { … }
bool BluetoothAdapterFactory::IsBluetoothSupported() { … }
bool BluetoothAdapterFactory::IsLowEnergySupported() { … }
void BluetoothAdapterFactory::GetAdapter(AdapterCallback callback) { … }
void BluetoothAdapterFactory::GetClassicAdapter(AdapterCallback callback) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
void BluetoothAdapterFactory::Shutdown() { … }
#endif
void BluetoothAdapterFactory::SetAdapterForTesting(
scoped_refptr<BluetoothAdapter> adapter) { … }
bool BluetoothAdapterFactory::HasSharedInstanceForTesting() { … }
#if BUILDFLAG(IS_CHROMEOS)
void BluetoothAdapterFactory::SetBleScanParserCallback(
BleScanParserCallback callback) {
Get()->ble_scan_parser_ = callback;
}
BluetoothAdapterFactory::BleScanParserCallback
BluetoothAdapterFactory::GetBleScanParserCallback() {
return Get()->ble_scan_parser_;
}
#endif
BluetoothAdapterFactory::GlobalOverrideValues::GlobalOverrideValues() = default;
BluetoothAdapterFactory::GlobalOverrideValues::~GlobalOverrideValues() =
default;
base::WeakPtr<BluetoothAdapterFactory::GlobalOverrideValues>
BluetoothAdapterFactory::GlobalOverrideValues::GetWeakPtr() { … }
std::unique_ptr<BluetoothAdapterFactory::GlobalOverrideValues>
BluetoothAdapterFactory::InitGlobalOverrideValues() { … }
void BluetoothAdapterFactory::AdapterInitialized() { … }
#if BUILDFLAG(IS_WIN)
void BluetoothAdapterFactory::ClassicAdapterInitialized() {
DCHECK(classic_adapter_);
DCHECK(classic_adapter_under_initialization_);
scoped_refptr<BluetoothAdapter> adapter =
std::move(classic_adapter_under_initialization_);
std::vector<AdapterCallback> callbacks =
std::move(classic_adapter_callbacks_);
for (auto& callback : callbacks)
std::move(callback).Run(adapter);
}
#endif
}