| 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 0e1f50a187aafb8e1519f77d97d9f17a4d637d88..fa4b8b6581ab760ffa7131cab4118991f958868c 100644
 | 
| --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp
 | 
| +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.cpp
 | 
| @@ -17,17 +17,43 @@
 | 
|  
 | 
|  namespace blink {
 | 
|  
 | 
| -BluetoothGATTCharacteristic::BluetoothGATTCharacteristic(PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic)
 | 
| -    : m_webCharacteristic(webCharacteristic)
 | 
| +BluetoothGATTCharacteristic::BluetoothGATTCharacteristic(ExecutionContext* context, PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic)
 | 
| +    : ActiveDOMObject(context)
 | 
| +    , m_webCharacteristic(webCharacteristic)
 | 
| +    , m_stopped(false)
 | 
|  {
 | 
| +    // See example in Source/platform/heap/ThreadState.h
 | 
| +    ThreadState::current()->registerPreFinalizer(this);
 | 
|  }
 | 
|  
 | 
| -BluetoothGATTCharacteristic* BluetoothGATTCharacteristic::take(ScriptPromiseResolver*, PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic)
 | 
| +BluetoothGATTCharacteristic* BluetoothGATTCharacteristic::take(ScriptPromiseResolver* resolver, PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic)
 | 
|  {
 | 
|      if (!webCharacteristic) {
 | 
|          return nullptr;
 | 
|      }
 | 
| -    return new BluetoothGATTCharacteristic(webCharacteristic);
 | 
| +    BluetoothGATTCharacteristic* characteristic = new BluetoothGATTCharacteristic(resolver->executionContext(), webCharacteristic);
 | 
| +    // See note in ActiveDOMObject about suspendIfNeeded.
 | 
| +    characteristic->suspendIfNeeded();
 | 
| +    return characteristic;
 | 
| +}
 | 
| +
 | 
| +void BluetoothGATTCharacteristic::stop()
 | 
| +{
 | 
| +    notifyCharacteristicObjectRemoved();
 | 
| +}
 | 
| +
 | 
| +void BluetoothGATTCharacteristic::dispose()
 | 
| +{
 | 
| +    notifyCharacteristicObjectRemoved();
 | 
| +}
 | 
| +
 | 
| +void BluetoothGATTCharacteristic::notifyCharacteristicObjectRemoved()
 | 
| +{
 | 
| +    if (!m_stopped) {
 | 
| +        m_stopped = true;
 | 
| +        WebBluetooth* webbluetooth = BluetoothSupplement::fromExecutionContext(ActiveDOMObject::executionContext());
 | 
| +        webbluetooth->characteristicObjectRemoved(m_webCharacteristic->characteristicInstanceID, this);
 | 
| +    }
 | 
|  }
 | 
|  
 | 
|  ScriptPromise BluetoothGATTCharacteristic::readValue(ScriptState* scriptState)
 | 
| @@ -63,4 +89,27 @@ ScriptPromise BluetoothGATTCharacteristic::writeValue(ScriptState* scriptState,
 | 
|      return promise;
 | 
|  }
 | 
|  
 | 
| +ScriptPromise BluetoothGATTCharacteristic::startNotifications(ScriptState* scriptState)
 | 
| +{
 | 
| +    WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(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::fromScriptState(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
 | 
| 
 |