bluetooth_advertisement_monitor_service_provider.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "device/bluetooth/dbus/bluetooth_advertisement_monitor_service_provider.h"
  5. #include "base/logging.h"
  6. #include "base/memory/ptr_util.h"
  7. #include "device/bluetooth/dbus/bluetooth_advertisement_monitor_service_provider_impl.h"
  8. #include "device/bluetooth/dbus/bluez_dbus_manager.h"
  9. #include "device/bluetooth/dbus/fake_bluetooth_advertisement_monitor_service_provider.h"
  10. namespace bluez {
  11. BluetoothAdvertisementMonitorServiceProvider::
  12. BluetoothAdvertisementMonitorServiceProvider() = default;
  13. BluetoothAdvertisementMonitorServiceProvider::
  14. ~BluetoothAdvertisementMonitorServiceProvider() = default;
  15. // static
  16. std::unique_ptr<BluetoothAdvertisementMonitorServiceProvider>
  17. BluetoothAdvertisementMonitorServiceProvider::Create(
  18. dbus::Bus* bus,
  19. const dbus::ObjectPath& object_path,
  20. std::unique_ptr<device::BluetoothLowEnergyScanFilter> filter,
  21. base::WeakPtr<BluetoothAdvertisementMonitorServiceProvider::Delegate>
  22. delegate) {
  23. if (!bluez::BluezDBusManager::Get()->IsUsingFakes()) {
  24. return std::make_unique<BluetoothAdvertisementMonitorServiceProviderImpl>(
  25. bus, object_path, std::move(filter), delegate);
  26. }
  27. #if defined(USE_REAL_DBUS_CLIENTS)
  28. LOG(FATAL) << "Fake is unavailable if USE_REAL_DBUS_CLIENTS is defined.";
  29. return nullptr;
  30. #else
  31. return std::make_unique<FakeBluetoothAdvertisementMonitorServiceProvider>(
  32. object_path, delegate);
  33. #endif // defined(USE_REAL_DBUS_CLIENTS)
  34. }
  35. } // namespace bluez