Example #1
0
void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects()
{
    TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
    Vector<UntracedMember<ContextLifecycleObserver>> snapshotOfObservers;
    copyToVector(m_observers, snapshotOfObservers);
    for (ContextLifecycleObserver* observer : snapshotOfObservers) {
        // It's possible that the ActiveDOMObject is already destructed.
        // See a FIXME above.
        if (m_observers.contains(observer)) {
            if (observer->observerType() != ContextLifecycleObserver::ActiveDOMObjectType)
                continue;
            ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(observer);
#if DCHECK_IS_ON()
            DCHECK_EQ(activeDOMObject->getExecutionContext(), context());
            DCHECK(activeDOMObject->suspendIfNeededCalled());
#endif
            activeDOMObject->stop();
        }
    }
}
Example #2
0
void ContextLifecycleNotifier::notifyResumingActiveDOMObjects()
{
    TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
    Vector<UntracedMember<ContextLifecycleObserver>> snapshotOfObservers;
    copyToVector(m_observers, snapshotOfObservers);
    for (ContextLifecycleObserver* observer : snapshotOfObservers) {
        // FIXME: Oilpan: At the moment, it's possible that a ActiveDOMObject
        // observer is destructed while iterating. Once we enable Oilpan by default
        // for all LifecycleObserver<T>s, we can remove the hack by making m_observers
        // a HeapHashSet<WeakMember<LifecycleObserver<T>>>.
        // (i.e., we can just iterate m_observers without taking a snapshot).
        // For more details, see https://codereview.chromium.org/247253002/.
        if (m_observers.contains(observer)) {
            if (observer->observerType() != ContextLifecycleObserver::ActiveDOMObjectType)
                continue;
            ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(observer);
#if DCHECK_IS_ON()
            DCHECK_EQ(activeDOMObject->getExecutionContext(), context());
            DCHECK(activeDOMObject->suspendIfNeededCalled());
#endif
            activeDOMObject->resume();
        }
    }
}