OLD | NEW |
(Empty) | |
| 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 |
| 5 #ifndef BluetoothRemoteGATTDescriptor_h |
| 6 #define BluetoothRemoteGATTDescriptor_h |
| 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "core/dom/DOMArrayPiece.h" |
| 10 #include "core/dom/DOMDataView.h" |
| 11 #include "modules/EventTargetModules.h" |
| 12 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" |
| 13 #include "modules/bluetooth/BluetoothRemoteGATTService.h" |
| 14 #include "platform/heap/Handle.h" |
| 15 #include "wtf/text/WTFString.h" |
| 16 #include <memory> |
| 17 |
| 18 namespace blink { |
| 19 |
| 20 class BluetoothRemoteGATTCharacteristic; |
| 21 class ScriptPromise; |
| 22 class ScriptState; |
| 23 |
| 24 // BluetoothRemoteGATTDescriptor represents a GATT Descriptor, which is |
| 25 // a basic data element that provides further information about a peripheral's |
| 26 // characteristic. |
| 27 class BluetoothRemoteGATTDescriptor final |
| 28 : public GarbageCollectedFinalized<BluetoothRemoteGATTDescriptor>, |
| 29 public ScriptWrappable { |
| 30 DEFINE_WRAPPERTYPEINFO(); |
| 31 |
| 32 public: |
| 33 BluetoothRemoteGATTDescriptor( |
| 34 mojom::blink::WebBluetoothRemoteGATTDescriptorPtr, |
| 35 BluetoothRemoteGATTCharacteristic*); |
| 36 |
| 37 static BluetoothRemoteGATTDescriptor* create( |
| 38 mojom::blink::WebBluetoothRemoteGATTDescriptorPtr, |
| 39 BluetoothRemoteGATTCharacteristic*); |
| 40 |
| 41 // IDL exposed interface: |
| 42 BluetoothRemoteGATTCharacteristic* characteristic() { |
| 43 return m_characteristic; |
| 44 } |
| 45 String uuid() { return m_descriptor->uuid; } |
| 46 DOMDataView* value() const { return m_value; } |
| 47 ScriptPromise readValue(ScriptState*); |
| 48 ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&); |
| 49 |
| 50 // Interface required by garbage collection. |
| 51 DECLARE_VIRTUAL_TRACE(); |
| 52 |
| 53 private: |
| 54 friend class DescriptorReadValueCallback; |
| 55 |
| 56 BluetoothRemoteGATTServer* getGatt() { return m_characteristic->gatt(); } |
| 57 |
| 58 mojom::blink::WebBluetoothRemoteGATTDescriptorPtr m_descriptor; |
| 59 Member<BluetoothRemoteGATTCharacteristic> m_characteristic; |
| 60 Member<DOMDataView> m_value; |
| 61 }; |
| 62 |
| 63 } // namespace blink |
| 64 |
| 65 #endif // BluetoothRemoteGATTDescriptor_h |
OLD | NEW |