fake_bluetooth_gatt_application_service_provider.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2016 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/fake_bluetooth_gatt_application_service_provider.h"
  5. #include <string>
  6. #include "base/logging.h"
  7. #include "device/bluetooth/dbus/bluez_dbus_manager.h"
  8. #include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h"
  9. namespace bluez {
  10. FakeBluetoothGattApplicationServiceProvider::
  11. FakeBluetoothGattApplicationServiceProvider(
  12. const dbus::ObjectPath& object_path,
  13. const std::map<dbus::ObjectPath, BluetoothLocalGattServiceBlueZ*>&
  14. services)
  15. : object_path_(object_path) {
  16. DVLOG(1) << "Creating Bluetooth GATT application: " << object_path_.value();
  17. FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
  18. static_cast<FakeBluetoothGattManagerClient*>(
  19. bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
  20. fake_bluetooth_gatt_manager_client->RegisterApplicationServiceProvider(this);
  21. BluetoothGattApplicationServiceProvider::CreateAttributeServiceProviders(
  22. nullptr, services);
  23. }
  24. FakeBluetoothGattApplicationServiceProvider::
  25. ~FakeBluetoothGattApplicationServiceProvider() {
  26. DVLOG(1) << "Cleaning up Bluetooth GATT application: "
  27. << object_path_.value();
  28. FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client =
  29. static_cast<FakeBluetoothGattManagerClient*>(
  30. bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient());
  31. fake_bluetooth_gatt_manager_client->UnregisterApplicationServiceProvider(
  32. this);
  33. }
  34. } // namespace bluez