bluetooth_gatt_characteristic_service_provider.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2014 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_gatt_characteristic_service_provider.h"
  5. #include "base/logging.h"
  6. #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider_impl.h"
  7. #include "device/bluetooth/dbus/bluez_dbus_manager.h"
  8. #include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provider.h"
  9. namespace bluez {
  10. BluetoothGattCharacteristicServiceProvider::
  11. BluetoothGattCharacteristicServiceProvider() = default;
  12. BluetoothGattCharacteristicServiceProvider::
  13. ~BluetoothGattCharacteristicServiceProvider() = default;
  14. // static
  15. BluetoothGattCharacteristicServiceProvider*
  16. BluetoothGattCharacteristicServiceProvider::Create(
  17. dbus::Bus* bus,
  18. const dbus::ObjectPath& object_path,
  19. std::unique_ptr<BluetoothGattAttributeValueDelegate> delegate,
  20. const std::string& uuid,
  21. const std::vector<std::string>& flags,
  22. const dbus::ObjectPath& service_path) {
  23. if (!bluez::BluezDBusManager::Get()->IsUsingFakes()) {
  24. return new BluetoothGattCharacteristicServiceProviderImpl(
  25. bus, object_path, std::move(delegate), uuid, flags, service_path);
  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 new FakeBluetoothGattCharacteristicServiceProvider(
  32. object_path, std::move(delegate), uuid, flags, service_path);
  33. #endif // defined(USE_REAL_DBUS_CLIENTS)
  34. }
  35. } // namespace bluez