bluetooth_remote_gatt_descriptor_win.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_WIN_H_
  5. #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_WIN_H_
  6. #include <memory>
  7. #include "base/files/file_path.h"
  8. #include "base/memory/raw_ptr.h"
  9. #include "base/memory/weak_ptr.h"
  10. #include "device/bluetooth/bluetooth_low_energy_defs_win.h"
  11. #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
  12. #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
  13. namespace base {
  14. class SequencedTaskRunner;
  15. }
  16. namespace device {
  17. class BluetoothRemoteGattCharacteristicWin;
  18. class BluetoothTaskManagerWin;
  19. class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattDescriptorWin
  20. : public BluetoothRemoteGattDescriptor {
  21. public:
  22. BluetoothRemoteGattDescriptorWin(
  23. BluetoothRemoteGattCharacteristicWin* parent_characteristic,
  24. BTH_LE_GATT_DESCRIPTOR* descriptor_info,
  25. scoped_refptr<base::SequencedTaskRunner>& ui_task_runner);
  26. BluetoothRemoteGattDescriptorWin(const BluetoothRemoteGattDescriptorWin&) =
  27. delete;
  28. BluetoothRemoteGattDescriptorWin& operator=(
  29. const BluetoothRemoteGattDescriptorWin&) = delete;
  30. ~BluetoothRemoteGattDescriptorWin() override;
  31. // Override BluetoothRemoteGattDescriptor interfaces.
  32. std::string GetIdentifier() const override;
  33. BluetoothUUID GetUUID() const override;
  34. std::vector<uint8_t>& GetValue() const override;
  35. BluetoothRemoteGattCharacteristic* GetCharacteristic() const override;
  36. BluetoothRemoteGattCharacteristic::Permissions GetPermissions()
  37. const override;
  38. void ReadRemoteDescriptor(ValueCallback callback) override;
  39. void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value,
  40. base::OnceClosure callback,
  41. ErrorCallback error_callback) override;
  42. uint16_t GetAttributeHandle() const;
  43. PBTH_LE_GATT_DESCRIPTOR GetWinDescriptorInfo() const {
  44. return descriptor_info_.get();
  45. }
  46. private:
  47. raw_ptr<BluetoothRemoteGattCharacteristicWin> parent_characteristic_;
  48. std::unique_ptr<BTH_LE_GATT_DESCRIPTOR> descriptor_info_;
  49. scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
  50. base::FilePath service_path_;
  51. scoped_refptr<BluetoothTaskManagerWin> task_manager_;
  52. BluetoothRemoteGattCharacteristic::Permissions descriptor_permissions_;
  53. BluetoothUUID descriptor_uuid_;
  54. std::string descriptor_identifier_;
  55. std::vector<uint8_t> descriptor_value_;
  56. base::WeakPtrFactory<BluetoothRemoteGattDescriptorWin> weak_ptr_factory_{
  57. this};
  58. };
  59. } // namespace device.
  60. #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_WIN_H_