fake_bluetooth_le_advertisement_service_provider.cc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2015 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_le_advertisement_service_provider.h"
  5. #include "base/logging.h"
  6. #include "device/bluetooth/dbus/bluez_dbus_manager.h"
  7. #include "device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h"
  8. namespace bluez {
  9. FakeBluetoothLEAdvertisementServiceProvider::
  10. FakeBluetoothLEAdvertisementServiceProvider(
  11. const dbus::ObjectPath& object_path,
  12. Delegate* delegate)
  13. : delegate_(delegate) {
  14. object_path_ = object_path;
  15. DVLOG(1) << "Creating Bluetooth Advertisement: " << object_path_.value();
  16. FakeBluetoothLEAdvertisingManagerClient*
  17. fake_bluetooth_profile_manager_client =
  18. static_cast<FakeBluetoothLEAdvertisingManagerClient*>(
  19. bluez::BluezDBusManager::Get()
  20. ->GetBluetoothLEAdvertisingManagerClient());
  21. fake_bluetooth_profile_manager_client->RegisterAdvertisementServiceProvider(
  22. this);
  23. }
  24. FakeBluetoothLEAdvertisementServiceProvider::
  25. ~FakeBluetoothLEAdvertisementServiceProvider() {
  26. DVLOG(1) << "Cleaning up Bluetooth Advertisement: " << object_path_.value();
  27. FakeBluetoothLEAdvertisingManagerClient*
  28. fake_bluetooth_profile_manager_client =
  29. static_cast<FakeBluetoothLEAdvertisingManagerClient*>(
  30. bluez::BluezDBusManager::Get()
  31. ->GetBluetoothLEAdvertisingManagerClient());
  32. fake_bluetooth_profile_manager_client->UnregisterAdvertisementServiceProvider(
  33. this);
  34. }
  35. void FakeBluetoothLEAdvertisementServiceProvider::Release() {
  36. DVLOG(1) << object_path_.value() << ": Release";
  37. delegate_->Released();
  38. }
  39. } // namespace bluez