Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h

Issue 1334763002: bluetooth: Subscribe to notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-origin
Patch Set: Fix global interface test Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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);
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 before the object gets garbage collected.
53 void dispose();
54
55 // Notify our embedder that we should stop any notifications.
56 // The function only notifies the embedder once.
57 void notifyCharacteristicObjectRemoved();
58
41 // Interface required by garbage collection. 59 // Interface required by garbage collection.
42 DEFINE_INLINE_TRACE() { } 60 DECLARE_VIRTUAL_TRACE();
43 61
44 // IDL exposed interface: 62 // IDL exposed interface:
45 String uuid() { return m_webCharacteristic->uuid; } 63 String uuid() { return m_webCharacteristic->uuid; }
46 ScriptPromise readValue(ScriptState*); 64 ScriptPromise readValue(ScriptState*);
47 ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&); 65 ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&);
66 ScriptPromise startNotifications(ScriptState*);
67 ScriptPromise stopNotifications(ScriptState*);
48 68
49 private: 69 private:
50 OwnPtr<WebBluetoothGATTCharacteristicInit> m_webCharacteristic; 70 OwnPtr<WebBluetoothGATTCharacteristicInit> m_webCharacteristic;
71 bool m_stopped;
51 }; 72 };
52 73
53 } // namespace blink 74 } // namespace blink
54 75
55 #endif // BluetoothGATTCharacteristic_h 76 #endif // BluetoothGATTCharacteristic_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698