Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1129)

Unified Diff: Source/core/page/PageLifecycleNotifier.cpp

Issue 968633002: Simplify lifecycle notifiers and observers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/page/PageLifecycleNotifier.cpp
diff --git a/Source/core/page/PageLifecycleNotifier.cpp b/Source/core/page/PageLifecycleNotifier.cpp
index 9d50b94f908dce42306c0e4ac3db764cddcd2e46..134676b30ed8f0be5b9e7ff4518e4d6673b80807 100644
--- a/Source/core/page/PageLifecycleNotifier.cpp
+++ b/Source/core/page/PageLifecycleNotifier.cpp
@@ -32,42 +32,32 @@
namespace blink {
PageLifecycleNotifier::PageLifecycleNotifier(Page* context)
- : LifecycleNotifier<Page>(context)
+ : LifecycleNotifier<Page, PageLifecycleObserver>(context)
{
}
-void PageLifecycleNotifier::addObserver(PageLifecycleNotifier::Observer* observer)
+void PageLifecycleNotifier::addObserver(PageLifecycleObserver* observer)
{
- if (observer->observerType() == Observer::PageLifecycleObserverType) {
- RELEASE_ASSERT(m_iterating != IteratingOverPageObservers);
- m_pageObservers.add(static_cast<PageLifecycleObserver*>(observer));
- }
-
- LifecycleNotifier<Page>::addObserver(observer);
+ LifecycleNotifier<Page, PageLifecycleObserver>::addObserver(observer);
}
-void PageLifecycleNotifier::removeObserver(PageLifecycleNotifier::Observer* observer)
+void PageLifecycleNotifier::removeObserver(PageLifecycleObserver* observer)
{
- if (observer->observerType() == Observer::PageLifecycleObserverType) {
- RELEASE_ASSERT(m_iterating != IteratingOverPageObservers);
- m_pageObservers.remove(static_cast<PageLifecycleObserver*>(observer));
- }
-
- LifecycleNotifier<Page>::removeObserver(observer);
+ LifecycleNotifier<Page, PageLifecycleObserver>::removeObserver(observer);
}
void PageLifecycleNotifier::notifyPageVisibilityChanged()
{
- TemporaryChange<IterationType> scope(m_iterating, IteratingOverPageObservers);
- for (PageLifecycleObserver* pageObserver : m_pageObservers)
- pageObserver->pageVisibilityChanged();
+ TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
+ for (PageLifecycleObserver* observer : m_observers)
+ observer->pageVisibilityChanged();
}
void PageLifecycleNotifier::notifyDidCommitLoad(LocalFrame* frame)
{
- TemporaryChange<IterationType> scope(m_iterating, IteratingOverPageObservers);
- for (PageLifecycleObserver* pageObserver : m_pageObservers)
- pageObserver->didCommitLoad(frame);
+ TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
+ for (PageLifecycleObserver* observer : m_observers)
+ observer->didCommitLoad(frame);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698