chromium/device/bluetooth/bluetooth_adapter_factory.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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;

// static
BluetoothAdapterFactory* BluetoothAdapterFactory::Get() {}

// static
bool BluetoothAdapterFactory::IsBluetoothSupported() {}

bool BluetoothAdapterFactory::IsLowEnergySupported() {}

void BluetoothAdapterFactory::GetAdapter(AdapterCallback callback) {}

void BluetoothAdapterFactory::GetClassicAdapter(AdapterCallback callback) {}

#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// static
void BluetoothAdapterFactory::Shutdown() {}
#endif

// static
void BluetoothAdapterFactory::SetAdapterForTesting(
    scoped_refptr<BluetoothAdapter> adapter) {}

// static
bool BluetoothAdapterFactory::HasSharedInstanceForTesting() {}

#if BUILDFLAG(IS_CHROMEOS)
// static
void BluetoothAdapterFactory::SetBleScanParserCallback(
    BleScanParserCallback callback) {
  Get()->ble_scan_parser_ = callback;
}

// static
BluetoothAdapterFactory::BleScanParserCallback
BluetoothAdapterFactory::GetBleScanParserCallback() {
  return Get()->ble_scan_parser_;
}
#endif  // BUILDFLAG(IS_CHROMEOS)

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_);

  // Move |adapter_under_initialization_| and |adapter_callbacks_| to avoid
  // potential re-entrancy issues while looping over the callbacks.
  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  // BUILDFLAG(IS_WIN)

}  // namespace device