| Index: Source/core/dom/DocumentLifecycleObserver.h
|
| diff --git a/Source/core/dom/DocumentLifecycleObserver.h b/Source/core/dom/DocumentLifecycleObserver.h
|
| index 511f909e6f92552c2e5ffd03362a46a8bd979caf..d6d0263fec75a9f57183cc0f9856edec55f4ba60 100644
|
| --- a/Source/core/dom/DocumentLifecycleObserver.h
|
| +++ b/Source/core/dom/DocumentLifecycleObserver.h
|
| @@ -27,10 +27,9 @@
|
| #define DocumentLifecycleObserver_h
|
|
|
| #include "core/dom/ContextDestructionObserver.h"
|
| -#include "core/dom/ContextLifecycleNotifier.h"
|
| #include "wtf/Assertions.h"
|
| #include "wtf/PassOwnPtr.h"
|
| -#include "wtf/TemporaryChange.h"
|
| +#include "wtf/Vector.h"
|
|
|
| namespace WebCore {
|
|
|
| @@ -39,47 +38,49 @@ class Document;
|
| class DocumentLifecycleObserver : public ContextDestructionObserver {
|
| public:
|
| explicit DocumentLifecycleObserver(Document*);
|
| - virtual ~DocumentLifecycleObserver();
|
| + virtual ~DocumentLifecycleObserver() { }
|
| virtual void documentWasDetached() { }
|
| virtual void documentWasDisposed() { }
|
| };
|
|
|
| -class DocumentLifecycleNotifier : public ContextLifecycleNotifier {
|
| +class DocumentLifecycleNotifier {
|
| public:
|
| - static PassOwnPtr<DocumentLifecycleNotifier> create(ScriptExecutionContext*);
|
| + static PassOwnPtr<DocumentLifecycleNotifier> create();
|
|
|
| void notifyDocumentWasDetached();
|
| void notifyDocumentWasDisposed();
|
|
|
| - virtual void addObserver(ContextDestructionObserver*, ContextDestructionObserver::Type as) OVERRIDE;
|
| - virtual void removeObserver(ContextDestructionObserver*, ContextDestructionObserver::Type as) OVERRIDE;
|
| + void addObserver(DocumentLifecycleObserver*);
|
|
|
| private:
|
| - explicit DocumentLifecycleNotifier(ScriptExecutionContext*);
|
| +#if ASSERT_DISABLED
|
| + DocumentLifecycleNotifier() { }
|
| + void startIteration() { }
|
| + void endIteration() { }
|
| +#else
|
| + DocumentLifecycleNotifier() : m_iterating(false) { }
|
| void startIteration() { m_iterating = true; }
|
| void endIteration() { m_iterating = false; }
|
| + bool m_iterating;
|
| +#endif
|
|
|
| - typedef HashSet<DocumentLifecycleObserver*> DocumentObserverSet;
|
| - DocumentObserverSet m_documentObservers;
|
| + Vector<DocumentLifecycleObserver*> m_observers; // Use Vector instead of HashSet for faster iteration
|
| };
|
|
|
| -inline PassOwnPtr<DocumentLifecycleNotifier> DocumentLifecycleNotifier::create(ScriptExecutionContext* context)
|
| -{
|
| - return adoptPtr(new DocumentLifecycleNotifier(context));
|
| -}
|
| -
|
| inline void DocumentLifecycleNotifier::notifyDocumentWasDetached()
|
| {
|
| - TemporaryChange<bool> scope(this->m_iterating, true);
|
| - for (DocumentObserverSet::iterator i = m_documentObservers.begin(); i != m_documentObservers.end(); ++i)
|
| - (*i)->documentWasDetached();
|
| + startIteration();
|
| + for (size_t i = 0; i < m_observers.size(); ++i)
|
| + m_observers[i]->documentWasDetached();
|
| + endIteration();
|
| }
|
|
|
| inline void DocumentLifecycleNotifier::notifyDocumentWasDisposed()
|
| {
|
| - TemporaryChange<bool> scope(this->m_iterating, true);
|
| - for (DocumentObserverSet::iterator i = m_documentObservers.begin(); i != m_documentObservers.end(); ++i)
|
| - (*i)->documentWasDisposed();
|
| + startIteration();
|
| + for (size_t i = 0; i < m_observers.size(); ++i)
|
| + m_observers[i]->documentWasDisposed();
|
| + endIteration();
|
| }
|
|
|
| } // namespace WebCore
|
|
|