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

Unified Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h

Issue 1382743002: bluetooth: Add characteristicvaluechanged event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-notifications-1
Patch Set: Address tkent's comments 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h
index e182232a1009726cec4464d484e2fa25eb0457d7..44c3d3a1b805ac878d48fc7ab7e528e3fa69e432 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.h
@@ -8,6 +8,7 @@
#include "bindings/core/v8/ScriptWrappable.h"
#include "core/dom/ActiveDOMObject.h"
#include "core/dom/DOMArrayPiece.h"
+#include "modules/EventTargetModules.h"
#include "platform/heap/Handle.h"
#include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristic.h"
#include "public/platform/modules/bluetooth/WebBluetoothGATTCharacteristicInit.h"
@@ -31,13 +32,13 @@ class ScriptState;
// "Interface required by CallbackPromiseAdapter" section and the
// CallbackPromiseAdapter class comments.
class BluetoothGATTCharacteristic final
- : public GarbageCollectedFinalized<BluetoothGATTCharacteristic>
- , public ScriptWrappable
+ : public RefCountedGarbageCollectedEventTargetWithInlineData<BluetoothGATTCharacteristic>
, public ActiveDOMObject
, public WebBluetoothGATTCharacteristic {
USING_PRE_FINALIZER(BluetoothGATTCharacteristic, dispose);
- WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BluetoothGATTCharacteristic);
DEFINE_WRAPPERTYPEINFO();
+ REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(BluetoothGATTCharacteristic);
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BluetoothGATTCharacteristic);
public:
explicit BluetoothGATTCharacteristic(ExecutionContext*, PassOwnPtr<WebBluetoothGATTCharacteristicInit>);
@@ -45,6 +46,9 @@ public:
using WebType = OwnPtr<WebBluetoothGATTCharacteristicInit>;
static BluetoothGATTCharacteristic* take(ScriptPromiseResolver*, PassOwnPtr<WebBluetoothGATTCharacteristicInit>);
+ // WebBluetoothGATTCharacteristic interface:
+ void dispatchCharacteristicValueChanged(const WebVector<uint8_t>& value) override;
+
// ActiveDOMObject interface.
void stop() override;
@@ -56,19 +60,28 @@ public:
// The function only notifies the embedder once.
void notifyCharacteristicObjectRemoved();
+ // EventTarget methods:
+ const AtomicString& interfaceName() const override;
+ ExecutionContext* executionContext() const;
+ bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr<EventListener>, bool useCapture) override;
+
// Interface required by garbage collection.
DECLARE_VIRTUAL_TRACE();
// IDL exposed interface:
String uuid() { return m_webCharacteristic->uuid; }
+ PassRefPtr<DOMArrayBuffer> value() const { return m_value; }
ScriptPromise readValue(ScriptState*);
ScriptPromise writeValue(ScriptState*, const DOMArrayPiece&);
ScriptPromise startNotifications(ScriptState*);
ScriptPromise stopNotifications(ScriptState*);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(characteristicvaluechanged);
+
private:
OwnPtr<WebBluetoothGATTCharacteristicInit> m_webCharacteristic;
bool m_stopped;
+ RefPtr<DOMArrayBuffer> m_value;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698