mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1140952 - Implement read/write value of a descriptor for GATT client API (webapi part). f=jocelyn, r=btian, r=mrbkap
This commit is contained in:
parent
7635978729
commit
f50af0f15c
@ -52,3 +52,29 @@ BluetoothGattDescriptor::WrapObject(JSContext* aContext,
|
||||
{
|
||||
return BluetoothGattDescriptorBinding::Wrap(aContext, this, aGivenProto);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothGattDescriptor::GetValue(JSContext* cx,
|
||||
JS::MutableHandle<JSObject*> aValue) const
|
||||
{
|
||||
MOZ_ASSERT(aValue);
|
||||
|
||||
aValue.set(mValue.IsEmpty()
|
||||
? nullptr
|
||||
: ArrayBuffer::Create(cx, mValue.Length(), mValue.Elements()));
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
BluetoothGattDescriptor::ReadValue(ErrorResult& aRv)
|
||||
{
|
||||
// TODO: This will be implemented by later patch set in the same bug.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
BluetoothGattDescriptor::WriteValue(
|
||||
const RootedTypedArray<ArrayBuffer>& aValue, ErrorResult& aRv)
|
||||
{
|
||||
// TODO: This will be implemented by later patch set in the same bug.
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/BluetoothGattDescriptorBinding.h"
|
||||
#include "mozilla/dom/bluetooth/BluetoothCommon.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
@ -40,6 +42,15 @@ public:
|
||||
aUuidStr = mUuidStr;
|
||||
}
|
||||
|
||||
void GetValue(JSContext* cx, JS::MutableHandle<JSObject*> aValue) const;
|
||||
|
||||
/****************************************************************************
|
||||
* Methods (Web API Implementation)
|
||||
***************************************************************************/
|
||||
already_AddRefed<Promise> ReadValue(ErrorResult& aRv);
|
||||
already_AddRefed<Promise> WriteValue(
|
||||
const RootedTypedArray<ArrayBuffer>& aValue, ErrorResult& aRv);
|
||||
|
||||
/****************************************************************************
|
||||
* Others
|
||||
***************************************************************************/
|
||||
@ -81,6 +92,11 @@ private:
|
||||
* UUID string of this GATT descriptor.
|
||||
*/
|
||||
nsString mUuidStr;
|
||||
|
||||
/**
|
||||
* Value of this GATT descriptor.
|
||||
*/
|
||||
nsTArray<uint8_t> mValue;
|
||||
};
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
@ -9,4 +9,10 @@ interface BluetoothGattDescriptor
|
||||
{
|
||||
readonly attribute BluetoothGattCharacteristic characteristic;
|
||||
readonly attribute DOMString uuid;
|
||||
readonly attribute ArrayBuffer? value;
|
||||
|
||||
[NewObject]
|
||||
Promise<ArrayBuffer> readValue();
|
||||
[NewObject]
|
||||
Promise<void> writeValue(ArrayBuffer value);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user