| Index: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp
|
| diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp
|
| index 1c386003578feff3e054182e966c08b99d9f42e7..0971a3ecbd774dfd6f253fc1d378a14662d5ba0c 100644
|
| --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp
|
| +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp
|
| @@ -31,8 +31,8 @@ BluetoothRemoteGATTCharacteristic::BluetoothRemoteGATTCharacteristic(
|
| : ContextLifecycleObserver(context),
|
| m_characteristic(std::move(characteristic)),
|
| m_service(service),
|
| - m_stopped(false),
|
| - m_device(device) {
|
| + m_device(device),
|
| + m_clientBinding(this) {
|
| m_properties =
|
| BluetoothCharacteristicProperties::Create(m_characteristic->properties);
|
| }
|
| @@ -50,8 +50,8 @@ void BluetoothRemoteGATTCharacteristic::SetValue(DOMDataView* domDataView) {
|
| m_value = domDataView;
|
| }
|
|
|
| -void BluetoothRemoteGATTCharacteristic::DispatchCharacteristicValueChanged(
|
| - const Vector<uint8_t>& value) {
|
| +void BluetoothRemoteGATTCharacteristic::RemoteCharacteristicValueChanged(
|
| + const WTF::Vector<uint8_t>& value) {
|
| if (!GetGatt()->connected())
|
| return;
|
| this->SetValue(BluetoothRemoteGATTUtils::ConvertWTFVectorToDataView(value));
|
| @@ -59,19 +59,12 @@ void BluetoothRemoteGATTCharacteristic::DispatchCharacteristicValueChanged(
|
| }
|
|
|
| void BluetoothRemoteGATTCharacteristic::contextDestroyed(ExecutionContext*) {
|
| - NotifyCharacteristicObjectRemoved();
|
| + Dispose();
|
| }
|
|
|
| void BluetoothRemoteGATTCharacteristic::Dispose() {
|
| - NotifyCharacteristicObjectRemoved();
|
| -}
|
| -
|
| -void BluetoothRemoteGATTCharacteristic::NotifyCharacteristicObjectRemoved() {
|
| - if (!m_stopped) {
|
| - m_stopped = true;
|
| - m_device->bluetooth()->CharacteristicObjectRemoved(
|
| - m_characteristic->instance_id);
|
| - }
|
| + if (m_clientBinding.is_bound())
|
| + m_clientBinding.Close();
|
| }
|
|
|
| const WTF::AtomicString& BluetoothRemoteGATTCharacteristic::interfaceName()
|
| @@ -88,12 +81,6 @@ void BluetoothRemoteGATTCharacteristic::addedEventListener(
|
| const AtomicString& eventType,
|
| RegisteredEventListener& registeredListener) {
|
| EventTargetWithInlineData::addedEventListener(eventType, registeredListener);
|
| - // 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) {
|
| - m_device->bluetooth()->RegisterCharacteristicObject(
|
| - m_characteristic->instance_id, this);
|
| - }
|
| }
|
|
|
| void BluetoothRemoteGATTCharacteristic::ReadValueCallback(
|
| @@ -116,6 +103,7 @@ void BluetoothRemoteGATTCharacteristic::ReadValueCallback(
|
| DOMDataView* domDataView =
|
| BluetoothRemoteGATTUtils::ConvertWTFVectorToDataView(value.value());
|
| SetValue(domDataView);
|
| + dispatchEvent(Event::create(EventTypeNames::characteristicvaluechanged));
|
| resolver->resolve(domDataView);
|
| } else {
|
| resolver->reject(BluetoothError::CreateDOMException(result));
|
| @@ -257,8 +245,10 @@ ScriptPromise BluetoothRemoteGATTCharacteristic::startNotifications(
|
| GetGatt()->AddToActiveAlgorithms(resolver);
|
|
|
| mojom::blink::WebBluetoothService* service = m_device->bluetooth()->Service();
|
| + mojom::blink::WebBluetoothCharacteristicClientAssociatedPtrInfo ptrInfo;
|
| + m_clientBinding.Bind(&ptrInfo);
|
| service->RemoteCharacteristicStartNotifications(
|
| - m_characteristic->instance_id,
|
| + m_characteristic->instance_id, std::move(ptrInfo),
|
| convertToBaseCallback(
|
| WTF::bind(&BluetoothRemoteGATTCharacteristic::NotificationsCallback,
|
| wrapPersistent(this), wrapPersistent(resolver))));
|
|
|