| 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 BluetoothRemoteGATTCharacteristic_h | 5 #ifndef BluetoothRemoteGATTCharacteristic_h |
| 6 #define BluetoothRemoteGATTCharacteristic_h | 6 #define BluetoothRemoteGATTCharacteristic_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 "core/dom/DOMDataView.h" |
| 12 #include "modules/EventTargetModules.h" | 12 #include "modules/EventTargetModules.h" |
| 13 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
| 14 #include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristic
.h" | 14 #include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristic
.h" |
| 15 #include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristic
Init.h" | 15 #include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristic
Init.h" |
| 16 #include "wtf/OwnPtr.h" | |
| 17 #include "wtf/PassOwnPtr.h" | |
| 18 #include "wtf/text/WTFString.h" | 16 #include "wtf/text/WTFString.h" |
| 17 #include <memory> |
| 19 | 18 |
| 20 namespace blink { | 19 namespace blink { |
| 21 | 20 |
| 22 class BluetoothCharacteristicProperties; | 21 class BluetoothCharacteristicProperties; |
| 23 class ExecutionContext; | 22 class ExecutionContext; |
| 24 class ScriptPromise; | 23 class ScriptPromise; |
| 25 class ScriptPromiseResolver; | 24 class ScriptPromiseResolver; |
| 26 class ScriptState; | 25 class ScriptState; |
| 27 | 26 |
| 28 // BluetoothRemoteGATTCharacteristic represents a GATT Characteristic, which is
a | 27 // BluetoothRemoteGATTCharacteristic represents a GATT Characteristic, which is
a |
| 29 // basic data element that provides further information about a peripheral's | 28 // basic data element that provides further information about a peripheral's |
| 30 // service. | 29 // service. |
| 31 // | 30 // |
| 32 // Callbacks providing WebBluetoothRemoteGATTCharacteristicInit objects are hand
led by | 31 // Callbacks providing WebBluetoothRemoteGATTCharacteristicInit objects are hand
led by |
| 33 // CallbackPromiseAdapter templatized with this class. See this class's | 32 // CallbackPromiseAdapter templatized with this class. See this class's |
| 34 // "Interface required by CallbackPromiseAdapter" section and the | 33 // "Interface required by CallbackPromiseAdapter" section and the |
| 35 // CallbackPromiseAdapter class comments. | 34 // CallbackPromiseAdapter class comments. |
| 36 class BluetoothRemoteGATTCharacteristic final | 35 class BluetoothRemoteGATTCharacteristic final |
| 37 : public EventTargetWithInlineData | 36 : public EventTargetWithInlineData |
| 38 , public ActiveDOMObject | 37 , public ActiveDOMObject |
| 39 , public WebBluetoothRemoteGATTCharacteristic { | 38 , public WebBluetoothRemoteGATTCharacteristic { |
| 40 USING_PRE_FINALIZER(BluetoothRemoteGATTCharacteristic, dispose); | 39 USING_PRE_FINALIZER(BluetoothRemoteGATTCharacteristic, dispose); |
| 41 DEFINE_WRAPPERTYPEINFO(); | 40 DEFINE_WRAPPERTYPEINFO(); |
| 42 USING_GARBAGE_COLLECTED_MIXIN(BluetoothRemoteGATTCharacteristic); | 41 USING_GARBAGE_COLLECTED_MIXIN(BluetoothRemoteGATTCharacteristic); |
| 43 public: | 42 public: |
| 44 explicit BluetoothRemoteGATTCharacteristic(ExecutionContext*, PassOwnPtr<Web
BluetoothRemoteGATTCharacteristicInit>); | 43 explicit BluetoothRemoteGATTCharacteristic(ExecutionContext*, std::unique_pt
r<WebBluetoothRemoteGATTCharacteristicInit>); |
| 45 | 44 |
| 46 // Interface required by CallbackPromiseAdapter. | 45 // Interface required by CallbackPromiseAdapter. |
| 47 using WebType = OwnPtr<WebBluetoothRemoteGATTCharacteristicInit>; | 46 using WebType = std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit>; |
| 48 static BluetoothRemoteGATTCharacteristic* take(ScriptPromiseResolver*, PassO
wnPtr<WebBluetoothRemoteGATTCharacteristicInit>); | 47 static BluetoothRemoteGATTCharacteristic* take(ScriptPromiseResolver*, std::
unique_ptr<WebBluetoothRemoteGATTCharacteristicInit>); |
| 49 | 48 |
| 50 // Save value. | 49 // Save value. |
| 51 void setValue(DOMDataView*); | 50 void setValue(DOMDataView*); |
| 52 | 51 |
| 53 // WebBluetoothRemoteGATTCharacteristic interface: | 52 // WebBluetoothRemoteGATTCharacteristic interface: |
| 54 void dispatchCharacteristicValueChanged(const WebVector<uint8_t>&) override; | 53 void dispatchCharacteristicValueChanged(const WebVector<uint8_t>&) override; |
| 55 | 54 |
| 56 // ActiveDOMObject interface. | 55 // ActiveDOMObject interface. |
| 57 void stop() override; | 56 void stop() override; |
| 58 | 57 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 81 ScriptPromise startNotifications(ScriptState*); | 80 ScriptPromise startNotifications(ScriptState*); |
| 82 ScriptPromise stopNotifications(ScriptState*); | 81 ScriptPromise stopNotifications(ScriptState*); |
| 83 | 82 |
| 84 DEFINE_ATTRIBUTE_EVENT_LISTENER(characteristicvaluechanged); | 83 DEFINE_ATTRIBUTE_EVENT_LISTENER(characteristicvaluechanged); |
| 85 | 84 |
| 86 protected: | 85 protected: |
| 87 // EventTarget overrides. | 86 // EventTarget overrides. |
| 88 void addedEventListener(const AtomicString& eventType, RegisteredEventListen
er&) override; | 87 void addedEventListener(const AtomicString& eventType, RegisteredEventListen
er&) override; |
| 89 | 88 |
| 90 private: | 89 private: |
| 91 OwnPtr<WebBluetoothRemoteGATTCharacteristicInit> m_webCharacteristic; | 90 std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit> m_webCharacteristi
c; |
| 92 bool m_stopped; | 91 bool m_stopped; |
| 93 Member<BluetoothCharacteristicProperties> m_properties; | 92 Member<BluetoothCharacteristicProperties> m_properties; |
| 94 Member<DOMDataView> m_value; | 93 Member<DOMDataView> m_value; |
| 95 }; | 94 }; |
| 96 | 95 |
| 97 } // namespace blink | 96 } // namespace blink |
| 98 | 97 |
| 99 #endif // BluetoothRemoteGATTCharacteristic_h | 98 #endif // BluetoothRemoteGATTCharacteristic_h |
| OLD | NEW |