#ifndef DEVICE_BLUETOOTH_CAST_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_CAST_H_
#define DEVICE_BLUETOOTH_CAST_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_CAST_H_
#include <stdint.h>
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
namespace chromecast {
namespace bluetooth {
class RemoteDescriptor;
}
}
namespace device {
class BluetoothRemoteGattCharacteristicCast;
class BluetoothRemoteGattDescriptorCast : public BluetoothRemoteGattDescriptor {
public:
BluetoothRemoteGattDescriptorCast(
BluetoothRemoteGattCharacteristicCast* characteristic,
scoped_refptr<chromecast::bluetooth::RemoteDescriptor> remote_descriptor);
BluetoothRemoteGattDescriptorCast(const BluetoothRemoteGattDescriptorCast&) =
delete;
BluetoothRemoteGattDescriptorCast& operator=(
const BluetoothRemoteGattDescriptorCast&) = delete;
~BluetoothRemoteGattDescriptorCast() override;
std::string GetIdentifier() const override;
BluetoothUUID GetUUID() const override;
BluetoothGattCharacteristic::Permissions GetPermissions() const override;
const std::vector<uint8_t>& GetValue() const override;
BluetoothRemoteGattCharacteristic* GetCharacteristic() const override;
void ReadRemoteDescriptor(ValueCallback callback) override;
void WriteRemoteDescriptor(base::span<const uint8_t> new_value,
base::OnceClosure callback,
ErrorCallback error_callback) override;
private:
void OnReadRemoteDescriptor(ValueCallback callback,
bool success,
const std::vector<uint8_t>& result);
void OnWriteRemoteDescriptor(const std::vector<uint8_t>& written_value,
base::OnceClosure callback,
ErrorCallback error_callback,
bool success);
BluetoothRemoteGattCharacteristicCast* const characteristic_;
scoped_refptr<chromecast::bluetooth::RemoteDescriptor> remote_descriptor_;
std::vector<uint8_t> value_;
base::WeakPtrFactory<BluetoothRemoteGattDescriptorCast> weak_factory_;
};
}
#endif