Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp

Issue 1942723004: Change EventTarget callback APIs for add/RemoveEventListenerInternal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gypi Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const WTF::AtomicString& BluetoothRemoteGATTCharacteristic::interfaceName() cons t 84 const WTF::AtomicString& BluetoothRemoteGATTCharacteristic::interfaceName() cons t
85 { 85 {
86 return EventTargetNames::BluetoothRemoteGATTCharacteristic; 86 return EventTargetNames::BluetoothRemoteGATTCharacteristic;
87 } 87 }
88 88
89 ExecutionContext* BluetoothRemoteGATTCharacteristic::getExecutionContext() const 89 ExecutionContext* BluetoothRemoteGATTCharacteristic::getExecutionContext() const
90 { 90 {
91 return ActiveDOMObject::getExecutionContext(); 91 return ActiveDOMObject::getExecutionContext();
92 } 92 }
93 93
94 bool BluetoothRemoteGATTCharacteristic::addEventListenerInternal(const AtomicStr ing& eventType, EventListener* listener, const EventListenerOptions& options) 94 void BluetoothRemoteGATTCharacteristic::addedEventListener(const AtomicString& e ventType, const RegisteredEventListener& registeredListener)
95 { 95 {
96 EventTargetWithInlineData::addedEventListener(eventType, registeredListener) ;
96 // We will also need to unregister a characteristic once all the event 97 // We will also need to unregister a characteristic once all the event
97 // listeners have been removed. See http://crbug.com/541390 98 // listeners have been removed. See http://crbug.com/541390
98 if (eventType == EventTypeNames::characteristicvaluechanged) { 99 if (eventType == EventTypeNames::characteristicvaluechanged) {
99 WebBluetooth* webbluetooth = BluetoothSupplement::fromExecutionContext(g etExecutionContext()); 100 WebBluetooth* webbluetooth = BluetoothSupplement::fromExecutionContext(g etExecutionContext());
bokan 2016/05/03 15:52:46 This used to get called even if the listener faile
dtapuska 2016/05/03 20:53:04 Added ortuno@
ortuno 2016/05/03 20:59:56 I wasn't aware addEventListenerInternal was called
100 webbluetooth->registerCharacteristicObject(m_webCharacteristic->characte risticInstanceID, this); 101 webbluetooth->registerCharacteristicObject(m_webCharacteristic->characte risticInstanceID, this);
101 } 102 }
102 return EventTarget::addEventListenerInternal(eventType, listener, options);
103 } 103 }
104 104
105 class ReadValueCallback : public WebBluetoothReadValueCallbacks { 105 class ReadValueCallback : public WebBluetoothReadValueCallbacks {
106 public: 106 public:
107 ReadValueCallback(BluetoothRemoteGATTCharacteristic* characteristic, ScriptP romiseResolver* resolver) : m_webCharacteristic(characteristic), m_resolver(reso lver) {} 107 ReadValueCallback(BluetoothRemoteGATTCharacteristic* characteristic, ScriptP romiseResolver* resolver) : m_webCharacteristic(characteristic), m_resolver(reso lver) {}
108 108
109 void onSuccess(const WebVector<uint8_t>& value) override 109 void onSuccess(const WebVector<uint8_t>& value) override
110 { 110 {
111 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) 111 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped())
112 return; 112 return;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) 212 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic)
213 { 213 {
214 visitor->trace(m_properties); 214 visitor->trace(m_properties);
215 visitor->trace(m_value); 215 visitor->trace(m_value);
216 EventTargetWithInlineData::trace(visitor); 216 EventTargetWithInlineData::trace(visitor);
217 ActiveDOMObject::trace(visitor); 217 ActiveDOMObject::trace(visitor);
218 } 218 }
219 219
220 } // namespace blink 220 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698