| Index: Source/core/dom/ContextLifecycleNotifier.cpp
|
| diff --git a/Source/core/dom/ContextLifecycleNotifier.cpp b/Source/core/dom/ContextLifecycleNotifier.cpp
|
| index 1c1b72f28d7ce8cef7b62ecce9954e34a58bf611..e9b4c0e4b31fde88e4bb8fa37ad096b5f978faf1 100644
|
| --- a/Source/core/dom/ContextLifecycleNotifier.cpp
|
| +++ b/Source/core/dom/ContextLifecycleNotifier.cpp
|
| @@ -28,46 +28,38 @@
|
| #include "config.h"
|
| #include "core/dom/ContextLifecycleNotifier.h"
|
|
|
| +#include "core/dom/ScriptExecutionContext.h"
|
| #include "core/dom/WebCoreMemoryInstrumentation.h"
|
| #include "wtf/TemporaryChange.h"
|
|
|
| namespace WebCore {
|
|
|
| ContextLifecycleNotifier::ContextLifecycleNotifier(ScriptExecutionContext* context)
|
| - : m_context(context)
|
| - , m_iterating(IteratingNone)
|
| - , m_inDestructor(false)
|
| + : SimpleLifecycleNotifier(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(SimpleLifecycleObserver* observer, SimpleLifecycleObserver::Type type)
|
| {
|
| - RELEASE_ASSERT(!m_inDestructor);
|
| + SimpleLifecycleNotifier::addObserver(observer, type);
|
| +
|
| RELEASE_ASSERT(m_iterating != IteratingOverContextObservers);
|
| - m_contextObservers.add(observer);
|
| - if (as == ContextLifecycleObserver::ActiveDOMObjectType) {
|
| + if (type == SimpleLifecycleObserver::ActiveDOMObjectType) {
|
| RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects);
|
| m_activeDOMObjects.add(static_cast<ActiveDOMObject*>(observer));
|
| }
|
| }
|
|
|
| -void ContextLifecycleNotifier::removeObserver(ContextLifecycleObserver* observer, ContextLifecycleObserver::Type as)
|
| +void ContextLifecycleNotifier::removeObserver(SimpleLifecycleObserver* observer, SimpleLifecycleObserver::Type type)
|
| {
|
| - RELEASE_ASSERT(!m_inDestructor);
|
| + SimpleLifecycleNotifier::removeObserver(observer, type);
|
| +
|
| RELEASE_ASSERT(m_iterating != IteratingOverContextObservers);
|
| - m_contextObservers.remove(observer);
|
| - if (as == ContextLifecycleObserver::ActiveDOMObjectType) {
|
| + if (type == SimpleLifecycleObserver::ActiveDOMObjectType) {
|
| RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects);
|
| m_activeDOMObjects.remove(static_cast<ActiveDOMObject*>(observer));
|
| }
|
| @@ -78,7 +70,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();
|
| }
|
| @@ -89,7 +81,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);
|
| }
|
| @@ -100,7 +92,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();
|
| }
|
| @@ -111,7 +103,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;
|
|
|