| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" | 5 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/DOMDataView.h" | 10 #include "core/dom/DOMDataView.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 const WTF::AtomicString& BluetoothRemoteGATTCharacteristic::interfaceName() cons
t | 85 const WTF::AtomicString& BluetoothRemoteGATTCharacteristic::interfaceName() cons
t |
| 86 { | 86 { |
| 87 return EventTargetNames::BluetoothRemoteGATTCharacteristic; | 87 return EventTargetNames::BluetoothRemoteGATTCharacteristic; |
| 88 } | 88 } |
| 89 | 89 |
| 90 ExecutionContext* BluetoothRemoteGATTCharacteristic::getExecutionContext() const | 90 ExecutionContext* BluetoothRemoteGATTCharacteristic::getExecutionContext() const |
| 91 { | 91 { |
| 92 return ActiveDOMObject::getExecutionContext(); | 92 return ActiveDOMObject::getExecutionContext(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool BluetoothRemoteGATTCharacteristic::addEventListenerInternal(const AtomicStr
ing& eventType, EventListener* listener, const EventListenerOptions& options) | 95 void BluetoothRemoteGATTCharacteristic::addedEventListener(const AtomicString& e
ventType, RegisteredEventListener& registeredListener) |
| 96 { | 96 { |
| 97 EventTargetWithInlineData::addedEventListener(eventType, registeredListener)
; |
| 97 // We will also need to unregister a characteristic once all the event | 98 // We will also need to unregister a characteristic once all the event |
| 98 // listeners have been removed. See http://crbug.com/541390 | 99 // listeners have been removed. See http://crbug.com/541390 |
| 99 if (eventType == EventTypeNames::characteristicvaluechanged) { | 100 if (eventType == EventTypeNames::characteristicvaluechanged) { |
| 100 WebBluetooth* webbluetooth = BluetoothSupplement::fromExecutionContext(g
etExecutionContext()); | 101 WebBluetooth* webbluetooth = BluetoothSupplement::fromExecutionContext(g
etExecutionContext()); |
| 101 webbluetooth->registerCharacteristicObject(m_webCharacteristic->characte
risticInstanceID, this); | 102 webbluetooth->registerCharacteristicObject(m_webCharacteristic->characte
risticInstanceID, this); |
| 102 } | 103 } |
| 103 return EventTarget::addEventListenerInternal(eventType, listener, options); | |
| 104 } | 104 } |
| 105 | 105 |
| 106 class ReadValueCallback : public WebBluetoothReadValueCallbacks { | 106 class ReadValueCallback : public WebBluetoothReadValueCallbacks { |
| 107 public: | 107 public: |
| 108 ReadValueCallback(BluetoothRemoteGATTCharacteristic* characteristic, ScriptP
romiseResolver* resolver) : m_webCharacteristic(characteristic), m_resolver(reso
lver) {} | 108 ReadValueCallback(BluetoothRemoteGATTCharacteristic* characteristic, ScriptP
romiseResolver* resolver) : m_webCharacteristic(characteristic), m_resolver(reso
lver) {} |
| 109 | 109 |
| 110 void onSuccess(const WebVector<uint8_t>& value) override | 110 void onSuccess(const WebVector<uint8_t>& value) override |
| 111 { | 111 { |
| 112 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) | 112 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex
t()->activeDOMObjectsAreStopped()) |
| 113 return; | 113 return; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) | 242 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) |
| 243 { | 243 { |
| 244 visitor->trace(m_properties); | 244 visitor->trace(m_properties); |
| 245 visitor->trace(m_value); | 245 visitor->trace(m_value); |
| 246 EventTargetWithInlineData::trace(visitor); | 246 EventTargetWithInlineData::trace(visitor); |
| 247 ActiveDOMObject::trace(visitor); | 247 ActiveDOMObject::trace(visitor); |
| 248 } | 248 } |
| 249 | 249 |
| 250 } // namespace blink | 250 } // namespace blink |
| OLD | NEW |