Chromium Code Reviews| Index: third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp |
| diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp |
| index fa4b8b6581ab760ffa7131cab4118991f958868c..16a629b7e33362b1c11a8f62d432a3c239f1c70f 100644 |
| --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp |
| +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp |
| @@ -10,6 +10,7 @@ |
| #include "bindings/core/v8/ScriptPromiseResolver.h" |
| #include "core/dom/DOMException.h" |
| #include "core/dom/ExceptionCode.h" |
| +#include "core/events/Event.h" |
| #include "modules/bluetooth/BluetoothError.h" |
| #include "modules/bluetooth/BluetoothSupplement.h" |
| #include "modules/bluetooth/ConvertWebVectorToArrayBuffer.h" |
| @@ -37,6 +38,16 @@ BluetoothGATTCharacteristic* BluetoothGATTCharacteristic::take(ScriptPromiseReso |
| return characteristic; |
| } |
| +void BluetoothGATTCharacteristic::dispatchCharacteristicValueChanged( |
| + const WebVector<uint8_t>& value) |
| +{ |
| + static_assert(sizeof(*value.data()) == 1, "uint8_t should be a single byte"); |
|
palmer
2015/10/19 19:23:33
This doesn't necessarily mean what you think it me
ortuno
2015/10/19 20:09:18
That assert is there to make sure that the byteLen
|
| + |
| + m_value = DOMArrayBuffer::create(value.data(), value.size()); |
| + |
| + dispatchEvent(Event::create(EventTypeNames::characteristicvaluechanged)); |
| +} |
| + |
| void BluetoothGATTCharacteristic::stop() |
| { |
| notifyCharacteristicObjectRemoved(); |
| @@ -56,6 +67,27 @@ void BluetoothGATTCharacteristic::notifyCharacteristicObjectRemoved() |
| } |
| } |
| +const WTF::AtomicString& BluetoothGATTCharacteristic::interfaceName() const |
| +{ |
| + return EventTargetNames::BluetoothGATTCharacteristic; |
| +} |
| + |
| +ExecutionContext* BluetoothGATTCharacteristic::executionContext() const |
| +{ |
| + return ActiveDOMObject::executionContext(); |
| +} |
| + |
| +bool BluetoothGATTCharacteristic::addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr<EventListener> listener, bool useCapture) |
| +{ |
| + // We will also need to unregister a characteristic once all the event |
| + // listeners have been removed. See http://crbug.com/541390 |
| + if (eventType == EventTypeNames::characteristicvaluechanged) { |
| + WebBluetooth* webbluetooth = BluetoothSupplement::fromExecutionContext(executionContext()); |
| + webbluetooth->registerCharacteristicObject(m_webCharacteristic->characteristicInstanceID, this); |
| + } |
| + return EventTarget::addEventListener(eventType, listener, useCapture); |
| +} |
| + |
| ScriptPromise BluetoothGATTCharacteristic::readValue(ScriptState* scriptState) |
| { |
| WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptState); |
| @@ -109,6 +141,7 @@ ScriptPromise BluetoothGATTCharacteristic::stopNotifications(ScriptState* script |
| DEFINE_TRACE(BluetoothGATTCharacteristic) |
| { |
| + RefCountedGarbageCollectedEventTargetWithInlineData<BluetoothGATTCharacteristic>::trace(visitor); |
| ActiveDOMObject::trace(visitor); |
| } |