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/DOMArrayPiece.h" | 10 #include "core/dom/DOMArrayPiece.h" |
10 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
12 #include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristic.h" | |
11 #include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristicInit.h " | 13 #include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristicInit.h " |
12 #include "wtf/OwnPtr.h" | 14 #include "wtf/OwnPtr.h" |
13 #include "wtf/PassOwnPtr.h" | 15 #include "wtf/PassOwnPtr.h" |
14 #include "wtf/text/WTFString.h" | 16 #include "wtf/text/WTFString.h" |
15 | 17 |
16 namespace blink { | 18 namespace blink { |
17 | 19 |
20 class ExecutionContext; | |
18 class ScriptPromise; | 21 class ScriptPromise; |
19 class ScriptPromiseResolver; | 22 class ScriptPromiseResolver; |
20 class ScriptState; | 23 class ScriptState; |
21 | 24 |
22 // BluetoothGATTCharacteristic represents a GATT Characteristic, which is a | 25 // BluetoothGATTCharacteristic represents a GATT Characteristic, which is a |
23 // basic data element that provides further information about a peripheral's | 26 // basic data element that provides further information about a peripheral's |
24 // service. | 27 // service. |
25 // | 28 // |
26 // Callbacks providing WebBluetoothGATTCharacteristicInit objects are handled by | 29 // Callbacks providing WebBluetoothGATTCharacteristicInit objects are handled by |
27 // CallbackPromiseAdapter templatized with this class. See this class's | 30 // CallbackPromiseAdapter templatized with this class. See this class's |
28 // "Interface required by CallbackPromiseAdapter" section and the | 31 // "Interface required by CallbackPromiseAdapter" section and the |
29 // CallbackPromiseAdapter class comments. | 32 // CallbackPromiseAdapter class comments. |
30 class BluetoothGATTCharacteristic final | 33 class BluetoothGATTCharacteristic final |
31 : public GarbageCollectedFinalized<BluetoothGATTCharacteristic> | 34 : public GarbageCollectedFinalized<BluetoothGATTCharacteristic> |
32 , public ScriptWrappable { | 35 , public ScriptWrappable |
36 , public ActiveDOMObject | |
37 , public WebBluetoothGATTCharacteristic { | |
38 USING_PRE_FINALIZER(BluetoothGATTCharacteristic, dispose); | |
39 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BluetoothGATTCharacteristic); | |
haraken
2015/10/07 01:22:33
You don't need this. (WebBluetoothGATTCharacterist
ortuno
2015/10/07 17:03:55
I tried that but the compiler complains when Oilpa
haraken
2015/10/08 00:51:52
ah, sorry; you're right.
WILL_BE_USING_GARBAGE_C
| |
33 DEFINE_WRAPPERTYPEINFO(); | 40 DEFINE_WRAPPERTYPEINFO(); |
34 public: | 41 public: |
35 explicit BluetoothGATTCharacteristic(PassOwnPtr<WebBluetoothGATTCharacterist icInit>); | 42 explicit BluetoothGATTCharacteristic(ExecutionContext*, PassOwnPtr<WebBlueto othGATTCharacteristicInit>); |
36 | 43 |
37 // Interface required by CallbackPromiseAdapter. | 44 // Interface required by CallbackPromiseAdapter. |
38 using WebType = OwnPtr<WebBluetoothGATTCharacteristicInit>; | 45 using WebType = OwnPtr<WebBluetoothGATTCharacteristicInit>; |
39 static BluetoothGATTCharacteristic* take(ScriptPromiseResolver*, PassOwnPtr< WebBluetoothGATTCharacteristicInit>); | 46 static BluetoothGATTCharacteristic* take(ScriptPromiseResolver*, PassOwnPtr< WebBluetoothGATTCharacteristicInit>); |
40 | 47 |
48 // ActiveDOMObject interface. | |
49 void stop() override; | |
50 | |
51 // USING_PRE_FINALIZER interface. | |
52 // Called when the object is getting garbage collected. | |
haraken
2015/10/07 01:22:33
Called _before_
ortuno
2015/10/07 17:03:55
Done.
| |
53 void dispose(); | |
54 | |
41 // Interface required by garbage collection. | 55 // Interface required by garbage collection. |
42 DEFINE_INLINE_TRACE() { } | 56 DECLARE_VIRTUAL_TRACE(); |
43 | 57 |
44 // IDL exposed interface: | 58 // IDL exposed interface: |
45 String uuid() { return m_webCharacteristic->uuid; } | 59 String uuid() { return m_webCharacteristic->uuid; } |
46 ScriptPromise readValue(ScriptState*); | 60 ScriptPromise readValue(ScriptState*); |
47 ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&); | 61 ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&); |
62 ScriptPromise startNotifications(ScriptState*); | |
63 ScriptPromise stopNotifications(ScriptState*); | |
48 | 64 |
49 private: | 65 private: |
50 OwnPtr<WebBluetoothGATTCharacteristicInit> m_webCharacteristic; | 66 OwnPtr<WebBluetoothGATTCharacteristicInit> m_webCharacteristic; |
67 bool m_stopped; | |
51 }; | 68 }; |
52 | 69 |
53 } // namespace blink | 70 } // namespace blink |
54 | 71 |
55 #endif // BluetoothGATTCharacteristic_h | 72 #endif // BluetoothGATTCharacteristic_h |
OLD | NEW |