| Index: Source/core/dom/ContextLifecycleNotifier.cpp
|
| diff --git a/Source/core/dom/ContextLifecycleNotifier.cpp b/Source/core/dom/ContextLifecycleNotifier.cpp
|
| index 6c77804b1dfd7d61e4043a9301e8c0944da9f4e5..f00e4310e16690f7ec10c6f948f60f232134a12b 100644
|
| --- a/Source/core/dom/ContextLifecycleNotifier.cpp
|
| +++ b/Source/core/dom/ContextLifecycleNotifier.cpp
|
| @@ -28,45 +28,37 @@
|
| #include "config.h"
|
| #include "core/dom/ContextLifecycleNotifier.h"
|
|
|
| +#include "core/dom/ScriptExecutionContext.h"
|
| #include "wtf/TemporaryChange.h"
|
|
|
| namespace WebCore {
|
|
|
| ContextLifecycleNotifier::ContextLifecycleNotifier(ScriptExecutionContext* context)
|
| - : m_context(context)
|
| - , m_iterating(IteratingNone)
|
| - , m_inDestructor(false)
|
| + : LifecycleNotifier(context)
|
| {
|
| }
|
|
|
| ContextLifecycleNotifier::~ContextLifecycleNotifier()
|
| {
|
| - m_inDestructor = true;
|
| - for (ContextObserverSet::iterator iter = m_contextObservers.begin(); iter != m_contextObservers.end(); iter = m_contextObservers.begin()) {
|
| - ContextLifecycleObserver* observer = *iter;
|
| - m_contextObservers.remove(observer);
|
| - ASSERT(observer->scriptExecutionContext() == m_context);
|
| - observer->contextDestroyed();
|
| - }
|
| }
|
|
|
| -void ContextLifecycleNotifier::addObserver(ContextLifecycleObserver* observer, ContextLifecycleObserver::Type as)
|
| +void ContextLifecycleNotifier::addObserver(LifecycleObserver* observer, LifecycleObserver::Type type)
|
| {
|
| - RELEASE_ASSERT(!m_inDestructor);
|
| + LifecycleNotifier::addObserver(observer, type);
|
| +
|
| RELEASE_ASSERT(m_iterating != IteratingOverContextObservers);
|
| - m_contextObservers.add(observer);
|
| - if (as == ContextLifecycleObserver::ActiveDOMObjectType) {
|
| + if (type == LifecycleObserver::ActiveDOMObjectType) {
|
| RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects);
|
| m_activeDOMObjects.add(static_cast<ActiveDOMObject*>(observer));
|
| }
|
| }
|
|
|
| -void ContextLifecycleNotifier::removeObserver(ContextLifecycleObserver* observer, ContextLifecycleObserver::Type as)
|
| +void ContextLifecycleNotifier::removeObserver(LifecycleObserver* observer, LifecycleObserver::Type type)
|
| {
|
| - RELEASE_ASSERT(!m_inDestructor);
|
| + LifecycleNotifier::removeObserver(observer, type);
|
| +
|
| RELEASE_ASSERT(m_iterating != IteratingOverContextObservers);
|
| - m_contextObservers.remove(observer);
|
| - if (as == ContextLifecycleObserver::ActiveDOMObjectType) {
|
| + if (type == LifecycleObserver::ActiveDOMObjectType) {
|
| RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects);
|
| m_activeDOMObjects.remove(static_cast<ActiveDOMObject*>(observer));
|
| }
|
| @@ -77,7 +69,7 @@ void ContextLifecycleNotifier::notifyResumingActiveDOMObjects()
|
| TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveDOMObjects);
|
| ActiveDOMObjectSet::iterator activeObjectsEnd = m_activeDOMObjects.end();
|
| for (ActiveDOMObjectSet::iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) {
|
| - ASSERT((*iter)->scriptExecutionContext() == m_context);
|
| + ASSERT((*iter)->scriptExecutionContext() == context());
|
| ASSERT((*iter)->suspendIfNeededCalled());
|
| (*iter)->resume();
|
| }
|
| @@ -88,7 +80,7 @@ void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects(ActiveDOMObject:
|
| TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveDOMObjects);
|
| ActiveDOMObjectSet::iterator activeObjectsEnd = m_activeDOMObjects.end();
|
| for (ActiveDOMObjectSet::iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) {
|
| - ASSERT((*iter)->scriptExecutionContext() == m_context);
|
| + ASSERT((*iter)->scriptExecutionContext() == context());
|
| ASSERT((*iter)->suspendIfNeededCalled());
|
| (*iter)->suspend(why);
|
| }
|
| @@ -99,7 +91,7 @@ void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects()
|
| TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveDOMObjects);
|
| ActiveDOMObjectSet::iterator activeObjectsEnd = m_activeDOMObjects.end();
|
| for (ActiveDOMObjectSet::iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) {
|
| - ASSERT((*iter)->scriptExecutionContext() == m_context);
|
| + ASSERT((*iter)->scriptExecutionContext() == context());
|
| ASSERT((*iter)->suspendIfNeededCalled());
|
| (*iter)->stop();
|
| }
|
| @@ -110,7 +102,7 @@ bool ContextLifecycleNotifier::canSuspendActiveDOMObjects()
|
| TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveDOMObjects);
|
| ActiveDOMObjectSet::iterator activeObjectsEnd = m_activeDOMObjects.end();
|
| for (ActiveDOMObjectSet::const_iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) {
|
| - ASSERT((*iter)->scriptExecutionContext() == m_context);
|
| + ASSERT((*iter)->scriptExecutionContext() == context());
|
| ASSERT((*iter)->suspendIfNeededCalled());
|
| if (!(*iter)->canSuspend())
|
| return false;
|
|
|