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

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

Issue 2718583002: Refactor WebBluetoothServiceClient in the web_bluetooth.mojom (Closed)
Patch Set: rebase Created 3 years, 9 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 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/ContextLifecycleObserver.h" 9 #include "core/dom/ContextLifecycleObserver.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 "modules/bluetooth/BluetoothRemoteGATTService.h" 13 #include "modules/bluetooth/BluetoothRemoteGATTService.h"
14 #include "mojo/public/cpp/bindings/associated_binding_set.h"
14 #include "platform/heap/Handle.h" 15 #include "platform/heap/Handle.h"
15 #include "public/platform/modules/bluetooth/web_bluetooth.mojom-blink.h" 16 #include "public/platform/modules/bluetooth/web_bluetooth.mojom-blink.h"
16 #include "wtf/text/WTFString.h" 17 #include "wtf/text/WTFString.h"
17 #include <memory>
18 18
19 namespace blink { 19 namespace blink {
20 20
21 class BluetoothCharacteristicProperties; 21 class BluetoothCharacteristicProperties;
22 class BluetoothDevice; 22 class BluetoothDevice;
23 class ExecutionContext; 23 class ExecutionContext;
24 class ScriptPromise; 24 class ScriptPromise;
25 class ScriptState; 25 class ScriptState;
26 26
27 // BluetoothRemoteGATTCharacteristic represents a GATT Characteristic, which is 27 // BluetoothRemoteGATTCharacteristic represents a GATT Characteristic, which is
28 // a basic data element that provides further information about a peripheral's 28 // a basic data element that provides further information about a peripheral's
29 // service. 29 // service.
30 // 30 //
31 // Callbacks providing WebBluetoothRemoteGATTCharacteristicInit objects are 31 // Callbacks providing WebBluetoothRemoteGATTCharacteristicInit objects are
32 // handled by CallbackPromiseAdapter templatized with this class. See this 32 // handled by CallbackPromiseAdapter templatized with this class. See this
33 // class's "Interface required by CallbackPromiseAdapter" section and the 33 // class's "Interface required by CallbackPromiseAdapter" section and the
34 // CallbackPromiseAdapter class comments. 34 // CallbackPromiseAdapter class comments.
35 class BluetoothRemoteGATTCharacteristic final 35 class BluetoothRemoteGATTCharacteristic final
36 : public EventTargetWithInlineData, 36 : public EventTargetWithInlineData,
37 public ContextLifecycleObserver { 37 public ContextLifecycleObserver,
38 public mojom::blink::WebBluetoothCharacteristicClient {
38 USING_PRE_FINALIZER(BluetoothRemoteGATTCharacteristic, Dispose); 39 USING_PRE_FINALIZER(BluetoothRemoteGATTCharacteristic, Dispose);
39 DEFINE_WRAPPERTYPEINFO(); 40 DEFINE_WRAPPERTYPEINFO();
40 USING_GARBAGE_COLLECTED_MIXIN(BluetoothRemoteGATTCharacteristic); 41 USING_GARBAGE_COLLECTED_MIXIN(BluetoothRemoteGATTCharacteristic);
41 42
42 public: 43 public:
43 explicit BluetoothRemoteGATTCharacteristic( 44 explicit BluetoothRemoteGATTCharacteristic(
44 ExecutionContext*, 45 ExecutionContext*,
45 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr, 46 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr,
46 BluetoothRemoteGATTService*, 47 BluetoothRemoteGATTService*,
47 BluetoothDevice*); 48 BluetoothDevice*);
48 49
49 static BluetoothRemoteGATTCharacteristic* Create( 50 static BluetoothRemoteGATTCharacteristic* Create(
50 ExecutionContext*, 51 ExecutionContext*,
51 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr, 52 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr,
52 BluetoothRemoteGATTService*, 53 BluetoothRemoteGATTService*,
53 BluetoothDevice*); 54 BluetoothDevice*);
54 55
55 // Save value. 56 // Save value.
56 void SetValue(DOMDataView*); 57 void SetValue(DOMDataView*);
57 58
58 void DispatchCharacteristicValueChanged(const Vector<uint8_t>& value); 59 // mojom::blink::WebBluetoothCharacteristicClient:
60 void RemoteCharacteristicValueChanged(
61 const WTF::Vector<uint8_t>& value) override;
59 62
60 // ContextLifecycleObserver interface. 63 // ContextLifecycleObserver interface.
61 void contextDestroyed(ExecutionContext*) override; 64 void contextDestroyed(ExecutionContext*) override;
62 65
63 // USING_PRE_FINALIZER interface. 66 // USING_PRE_FINALIZER interface.
64 // Called before the object gets garbage collected. 67 // Called before the object gets garbage collected.
65 void Dispose(); 68 void Dispose();
66 69
67 // Notify our embedder that we should stop any notifications.
68 // The function only notifies the embedder once.
69 void NotifyCharacteristicObjectRemoved();
70
71 // EventTarget methods: 70 // EventTarget methods:
72 const AtomicString& interfaceName() const override; 71 const AtomicString& interfaceName() const override;
73 ExecutionContext* getExecutionContext() const; 72 ExecutionContext* getExecutionContext() const;
74 73
75 // Interface required by garbage collection. 74 // Interface required by garbage collection.
76 DECLARE_VIRTUAL_TRACE(); 75 DECLARE_VIRTUAL_TRACE();
77 76
78 // IDL exposed interface: 77 // IDL exposed interface:
79 BluetoothRemoteGATTService* service() { return m_service; } 78 BluetoothRemoteGATTService* service() { return m_service; }
80 String uuid() { return m_characteristic->uuid; } 79 String uuid() { return m_characteristic->uuid; }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 mojom::blink::WebBluetoothGATTQueryQuantity, 122 mojom::blink::WebBluetoothGATTQueryQuantity,
124 ScriptPromiseResolver*, 123 ScriptPromiseResolver*,
125 mojom::blink::WebBluetoothResult, 124 mojom::blink::WebBluetoothResult,
126 Optional<Vector<mojom::blink::WebBluetoothRemoteGATTDescriptorPtr>> 125 Optional<Vector<mojom::blink::WebBluetoothRemoteGATTDescriptorPtr>>
127 descriptors); 126 descriptors);
128 127
129 DOMException* CreateInvalidCharacteristicError(); 128 DOMException* CreateInvalidCharacteristicError();
130 129
131 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr m_characteristic; 130 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr m_characteristic;
132 Member<BluetoothRemoteGATTService> m_service; 131 Member<BluetoothRemoteGATTService> m_service;
133 bool m_stopped;
134 Member<BluetoothCharacteristicProperties> m_properties; 132 Member<BluetoothCharacteristicProperties> m_properties;
135 Member<DOMDataView> m_value; 133 Member<DOMDataView> m_value;
136 Member<BluetoothDevice> m_device; 134 Member<BluetoothDevice> m_device;
135 mojo::AssociatedBindingSet<mojom::blink::WebBluetoothCharacteristicClient>
136 m_clientBindings;
137 }; 137 };
138 138
139 } // namespace blink 139 } // namespace blink
140 140
141 #endif // BluetoothRemoteGATTCharacteristic_h 141 #endif // BluetoothRemoteGATTCharacteristic_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698