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 1627bbf86c6766cfdad4791a89cd64c151f9f436..b06ca3821b70f52051975ba0c6ad0428a38f6bd8 100644 |
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp |
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp |
@@ -17,17 +17,26 @@ |
namespace blink { |
-BluetoothGATTCharacteristic::BluetoothGATTCharacteristic(PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic) |
- : m_webCharacteristic(webCharacteristic) |
+BluetoothGATTCharacteristic::BluetoothGATTCharacteristic(ExecutionContext* context, PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic) |
+ : ActiveDOMObject(context) |
+ , m_webCharacteristic(webCharacteristic) |
{ |
+ // See note in ActiveDOMObject about suspendIfNeeded. |
+ suspendIfNeeded(); |
} |
-BluetoothGATTCharacteristic* BluetoothGATTCharacteristic::take(ScriptPromiseResolver*, PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic) |
+BluetoothGATTCharacteristic* BluetoothGATTCharacteristic::take(ScriptPromiseResolver* resolver, PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic) |
{ |
if (!webCharacteristic) { |
return nullptr; |
} |
- return new BluetoothGATTCharacteristic(webCharacteristic); |
+ return new BluetoothGATTCharacteristic(resolver->executionContext(), webCharacteristic); |
+} |
+ |
+void BluetoothGATTCharacteristic::stop() |
+{ |
+ WebBluetooth* webbluetooth = BluetoothSupplement::from(ActiveDOMObject::executionContext()); |
+ webbluetooth->characteristicObjectRemoved(m_webCharacteristic->characteristicInstanceID, this); |
} |
ScriptPromise BluetoothGATTCharacteristic::readValue(ScriptState* scriptState) |
@@ -63,4 +72,27 @@ ScriptPromise BluetoothGATTCharacteristic::writeValue(ScriptState* scriptState, |
return promise; |
} |
+ScriptPromise BluetoothGATTCharacteristic::startNotifications(ScriptState* scriptState) |
+{ |
+ WebBluetooth* webbluetooth = BluetoothSupplement::from(scriptState); |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ webbluetooth->startNotifications(m_webCharacteristic->characteristicInstanceID, this, new CallbackPromiseAdapter<void, BluetoothError>(resolver)); |
+ return promise; |
+} |
+ |
+ScriptPromise BluetoothGATTCharacteristic::stopNotifications(ScriptState* scriptState) |
+{ |
+ WebBluetooth* webbluetooth = BluetoothSupplement::from(scriptState); |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ webbluetooth->stopNotifications(m_webCharacteristic->characteristicInstanceID, this, new CallbackPromiseAdapter<void, BluetoothError>(resolver)); |
+ return promise; |
+} |
+ |
+DEFINE_TRACE(BluetoothGATTCharacteristic) |
+{ |
+ ActiveDOMObject::trace(visitor); |
+} |
+ |
} // namespace blink |