OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BluetoothGATTCharacteristic_h | 5 #ifndef BluetoothGATTCharacteristic_h |
6 #define BluetoothGATTCharacteristic_h | 6 #define BluetoothGATTCharacteristic_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
9 #include "core/dom/ActiveDOMObject.h" | 9 #include "core/dom/ActiveDOMObject.h" |
10 #include "core/dom/DOMArrayPiece.h" | 10 #include "core/dom/DOMArrayPiece.h" |
| 11 #include "core/dom/DOMDataView.h" |
11 #include "modules/EventTargetModules.h" | 12 #include "modules/EventTargetModules.h" |
12 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
13 #include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristic.h" | 14 #include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristic.h" |
14 #include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristicInit.h
" | 15 #include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristicInit.h
" |
15 #include "wtf/OwnPtr.h" | 16 #include "wtf/OwnPtr.h" |
16 #include "wtf/PassOwnPtr.h" | 17 #include "wtf/PassOwnPtr.h" |
17 #include "wtf/text/WTFString.h" | 18 #include "wtf/text/WTFString.h" |
18 | 19 |
19 namespace blink { | 20 namespace blink { |
20 | 21 |
(...skipping 20 matching lines...) Expand all Loading... |
41 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(BluetoothGATTCharacteristic); | 42 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(BluetoothGATTCharacteristic); |
42 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BluetoothGATTCharacteristic); | 43 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BluetoothGATTCharacteristic); |
43 public: | 44 public: |
44 explicit BluetoothGATTCharacteristic(ExecutionContext*, PassOwnPtr<WebBlueto
othGATTCharacteristicInit>); | 45 explicit BluetoothGATTCharacteristic(ExecutionContext*, PassOwnPtr<WebBlueto
othGATTCharacteristicInit>); |
45 | 46 |
46 // Interface required by CallbackPromiseAdapter. | 47 // Interface required by CallbackPromiseAdapter. |
47 using WebType = OwnPtr<WebBluetoothGATTCharacteristicInit>; | 48 using WebType = OwnPtr<WebBluetoothGATTCharacteristicInit>; |
48 static BluetoothGATTCharacteristic* take(ScriptPromiseResolver*, PassOwnPtr<
WebBluetoothGATTCharacteristicInit>); | 49 static BluetoothGATTCharacteristic* take(ScriptPromiseResolver*, PassOwnPtr<
WebBluetoothGATTCharacteristicInit>); |
49 | 50 |
50 // Save value. | 51 // Save value. |
51 void setValue(const PassRefPtr<DOMArrayBuffer>&); | 52 void setValue(const PassRefPtr<DOMDataView>&); |
52 | 53 |
53 // WebBluetoothGATTCharacteristic interface: | 54 // WebBluetoothGATTCharacteristic interface: |
54 void dispatchCharacteristicValueChanged(const WebVector<uint8_t>&) override; | 55 void dispatchCharacteristicValueChanged(const WebVector<uint8_t>&) override; |
55 | 56 |
56 // ActiveDOMObject interface. | 57 // ActiveDOMObject interface. |
57 void stop() override; | 58 void stop() override; |
58 | 59 |
59 // USING_PRE_FINALIZER interface. | 60 // USING_PRE_FINALIZER interface. |
60 // Called before the object gets garbage collected. | 61 // Called before the object gets garbage collected. |
61 void dispose(); | 62 void dispose(); |
62 | 63 |
63 // Notify our embedder that we should stop any notifications. | 64 // Notify our embedder that we should stop any notifications. |
64 // The function only notifies the embedder once. | 65 // The function only notifies the embedder once. |
65 void notifyCharacteristicObjectRemoved(); | 66 void notifyCharacteristicObjectRemoved(); |
66 | 67 |
67 // EventTarget methods: | 68 // EventTarget methods: |
68 const AtomicString& interfaceName() const override; | 69 const AtomicString& interfaceName() const override; |
69 ExecutionContext* executionContext() const; | 70 ExecutionContext* executionContext() const; |
70 | 71 |
71 // Interface required by garbage collection. | 72 // Interface required by garbage collection. |
72 DECLARE_VIRTUAL_TRACE(); | 73 DECLARE_VIRTUAL_TRACE(); |
73 | 74 |
74 // IDL exposed interface: | 75 // IDL exposed interface: |
75 String uuid() { return m_webCharacteristic->uuid; } | 76 String uuid() { return m_webCharacteristic->uuid; } |
76 | 77 |
77 BluetoothCharacteristicProperties* properties() { return m_properties; } | 78 BluetoothCharacteristicProperties* properties() { return m_properties; } |
78 PassRefPtr<DOMArrayBuffer> value() const { return m_value; } | 79 PassRefPtr<DOMDataView> value() const { return m_value; } |
79 ScriptPromise readValue(ScriptState*); | 80 ScriptPromise readValue(ScriptState*); |
80 ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&); | 81 ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&); |
81 ScriptPromise startNotifications(ScriptState*); | 82 ScriptPromise startNotifications(ScriptState*); |
82 ScriptPromise stopNotifications(ScriptState*); | 83 ScriptPromise stopNotifications(ScriptState*); |
83 | 84 |
84 DEFINE_ATTRIBUTE_EVENT_LISTENER(characteristicvaluechanged); | 85 DEFINE_ATTRIBUTE_EVENT_LISTENER(characteristicvaluechanged); |
85 | 86 |
86 protected: | 87 protected: |
87 // EventTarget overrides. | 88 // EventTarget overrides. |
88 bool addEventListenerInternal(const AtomicString& eventType, PassRefPtrWillB
eRawPtr<EventListener>, const EventListenerOptions&) override; | 89 bool addEventListenerInternal(const AtomicString& eventType, PassRefPtrWillB
eRawPtr<EventListener>, const EventListenerOptions&) override; |
89 | 90 |
90 private: | 91 private: |
91 OwnPtr<WebBluetoothGATTCharacteristicInit> m_webCharacteristic; | 92 OwnPtr<WebBluetoothGATTCharacteristicInit> m_webCharacteristic; |
92 bool m_stopped; | 93 bool m_stopped; |
93 Member<BluetoothCharacteristicProperties> m_properties; | 94 Member<BluetoothCharacteristicProperties> m_properties; |
94 RefPtr<DOMArrayBuffer> m_value; | 95 RefPtr<DOMDataView> m_value; |
95 }; | 96 }; |
96 | 97 |
97 } // namespace blink | 98 } // namespace blink |
98 | 99 |
99 #endif // BluetoothGATTCharacteristic_h | 100 #endif // BluetoothGATTCharacteristic_h |
OLD | NEW |