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();
}
Example #3
0
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;
}
Example #4
0
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();
}
Example #6
0
void ImageCapture::contextDestroyed()
{
    removeAllEventListeners();
    m_serviceRequests.clear();
    DCHECK(!hasEventListeners());
}
Example #7
0
void GameFatherLayer::onExit()
{
	Layer::onExit();
	auto eventdispatcher=Director::getInstance()->getEventDispatcher();
	eventdispatcher->removeAllEventListeners();
}