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/DOMArrayPiece.h" | 9 #include "core/dom/DOMArrayPiece.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
11 #include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristic.h" | 11 #include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristic.h" |
| 12 #include "wtf/OwnPtr.h" |
12 #include "wtf/PassOwnPtr.h" | 13 #include "wtf/PassOwnPtr.h" |
13 #include "wtf/text/WTFString.h" | 14 #include "wtf/text/WTFString.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 | 17 |
17 class ScriptPromise; | 18 class ScriptPromise; |
18 class ScriptPromiseResolver; | 19 class ScriptPromiseResolver; |
19 class ScriptState; | 20 class ScriptState; |
20 | 21 |
21 // BluetoothGATTCharacteristic represents a GATT Characteristic, which is a | 22 // BluetoothGATTCharacteristic represents a GATT Characteristic, which is a |
22 // basic data element that provides further information about a peripheral's | 23 // basic data element that provides further information about a peripheral's |
23 // service. | 24 // service. |
24 // | 25 // |
25 // Callbacks providing WebBluetoothGATTCharacteristic objects are handled by | 26 // Callbacks providing WebBluetoothGATTCharacteristic objects are handled by |
26 // CallbackPromiseAdapter templatized with this class. See this class's | 27 // CallbackPromiseAdapter templatized with this class. See this class's |
27 // "Interface required by CallbackPromiseAdapter" section and the | 28 // "Interface required by CallbackPromiseAdapter" section and the |
28 // CallbackPromiseAdapter class comments. | 29 // CallbackPromiseAdapter class comments. |
29 class BluetoothGATTCharacteristic final | 30 class BluetoothGATTCharacteristic final |
30 : public GarbageCollectedFinalized<BluetoothGATTCharacteristic> | 31 : public GarbageCollectedFinalized<BluetoothGATTCharacteristic> |
31 , public ScriptWrappable { | 32 , public ScriptWrappable { |
32 DEFINE_WRAPPERTYPEINFO(); | 33 DEFINE_WRAPPERTYPEINFO(); |
33 public: | 34 public: |
34 explicit BluetoothGATTCharacteristic(PassOwnPtr<WebBluetoothGATTCharacterist
ic>); | 35 explicit BluetoothGATTCharacteristic(PassOwnPtr<WebBluetoothGATTCharacterist
ic>); |
35 | 36 |
36 // Interface required by CallbackPromiseAdapter. | 37 // Interface required by CallbackPromiseAdapter. |
37 typedef WebBluetoothGATTCharacteristic WebType; | 38 using WebType = OwnPtr<WebBluetoothGATTCharacteristic>; |
38 static BluetoothGATTCharacteristic* take(ScriptPromiseResolver* , PassOwnPtr
<WebBluetoothGATTCharacteristic>); | 39 static BluetoothGATTCharacteristic* take(ScriptPromiseResolver* , PassOwnPtr
<WebBluetoothGATTCharacteristic>); |
39 | 40 |
40 // Interface required by garbage collection. | 41 // Interface required by garbage collection. |
41 DEFINE_INLINE_TRACE() { } | 42 DEFINE_INLINE_TRACE() { } |
42 | 43 |
43 // IDL exposed interface: | 44 // IDL exposed interface: |
44 String uuid() { return m_webCharacteristic->uuid; } | 45 String uuid() { return m_webCharacteristic->uuid; } |
45 ScriptPromise readValue(ScriptState*); | 46 ScriptPromise readValue(ScriptState*); |
46 ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&); | 47 ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&); |
47 | 48 |
48 private: | 49 private: |
49 OwnPtr<WebBluetoothGATTCharacteristic> m_webCharacteristic; | 50 OwnPtr<WebBluetoothGATTCharacteristic> m_webCharacteristic; |
50 }; | 51 }; |
51 | 52 |
52 } // namespace blink | 53 } // namespace blink |
53 | 54 |
54 #endif // BluetoothGATTCharacteristic_h | 55 #endif // BluetoothGATTCharacteristic_h |
OLD | NEW |