void WorkerGlobalScope::dispose() { ASSERT(thread()->isCurrentThread()); stopActiveDOMObjects(); // Event listeners would keep DOMWrapperWorld objects alive for too long. Also, they have references to JS objects, // which become dangling once Heap is destroyed. for (auto it = m_eventListeners.begin(); it != m_eventListeners.end(); ) { RawPtr<V8AbstractEventListener> listener = *it; // clearListenerObject() will unregister the listener from // m_eventListeners, and invalidate the iterator, so we have to advance // it first. ++it; listener->clearListenerObject(); } removeAllEventListeners(); clearScript(); clearInspector(); m_eventQueue->close(); // We do not clear the thread field of the // WorkerGlobalScope. Other objects keep the worker global scope // alive because they need its thread field to check that work is // being carried out on the right thread. We therefore cannot clear // the thread field before all references to the worker global // scope are gone. }
EventDispatcher::~EventDispatcher() { // Clear internal custom listener IDs from set, // so removeAllEventListeners would clean internal custom listeners. _internalCustomListenerIDs.clear(); removeAllEventListeners(); }
void WorkerGlobalScope::dispose() { DCHECK(thread()->isCurrentThread()); // Event listeners would keep DOMWrapperWorld objects alive for too long. // Also, they have references to JS objects, which become dangling once Heap // is destroyed. for (auto it = m_eventListeners.begin(); it != m_eventListeners.end();) { V8AbstractEventListener* listener = *it; // clearListenerObject() will unregister the listener from // m_eventListeners, and invalidate the iterator, so we have to advance // it first. ++it; listener->clearListenerObject(); } removeAllEventListeners(); m_scriptController->dispose(); m_scriptController.clear(); m_eventQueue->close(); m_thread = nullptr; }
void IDBDatabase::stop() { LOG(IndexedDB, "IDBDatabase::stop - %" PRIu64, m_databaseConnectionIdentifier); ASSERT(&originThread() == &Thread::current()); removeAllEventListeners(); Vector<IDBResourceIdentifier> transactionIdentifiers; transactionIdentifiers.reserveInitialCapacity(m_activeTransactions.size()); for (auto& id : m_activeTransactions.keys()) transactionIdentifiers.uncheckedAppend(id); for (auto& id : transactionIdentifiers) { IDBTransaction* transaction = m_activeTransactions.get(id); if (transaction) transaction->stop(); } close(); }
EventDispatcher::~EventDispatcher() { removeAllEventListeners(); }
void ImageCapture::contextDestroyed() { removeAllEventListeners(); m_serviceRequests.clear(); DCHECK(!hasEventListeners()); }
void GameFatherLayer::onExit() { Layer::onExit(); auto eventdispatcher=Director::getInstance()->getEventDispatcher(); eventdispatcher->removeAllEventListeners(); }