| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/page/PageLifecycleNotifier.h" | 28 #include "core/page/PageLifecycleNotifier.h" |
| 29 | 29 |
| 30 #include "core/page/PageLifecycleObserver.h" | 30 #include "core/page/PageLifecycleObserver.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 PageLifecycleNotifier::PageLifecycleNotifier(Page* context) | 34 PageLifecycleNotifier::PageLifecycleNotifier(Page* context) |
| 35 : LifecycleNotifier<Page>(context) | 35 : LifecycleNotifier<Page, PageLifecycleObserver>(context) |
| 36 { | 36 { |
| 37 } | 37 } |
| 38 | 38 |
| 39 void PageLifecycleNotifier::addObserver(PageLifecycleNotifier::Observer* observe
r) | 39 void PageLifecycleNotifier::addObserver(PageLifecycleObserver* observer) |
| 40 { | 40 { |
| 41 if (observer->observerType() == Observer::PageLifecycleObserverType) { | 41 LifecycleNotifier<Page, PageLifecycleObserver>::addObserver(observer); |
| 42 RELEASE_ASSERT(m_iterating != IteratingOverPageObservers); | |
| 43 m_pageObservers.add(static_cast<PageLifecycleObserver*>(observer)); | |
| 44 } | |
| 45 | |
| 46 LifecycleNotifier<Page>::addObserver(observer); | |
| 47 } | 42 } |
| 48 | 43 |
| 49 void PageLifecycleNotifier::removeObserver(PageLifecycleNotifier::Observer* obse
rver) | 44 void PageLifecycleNotifier::removeObserver(PageLifecycleObserver* observer) |
| 50 { | 45 { |
| 51 if (observer->observerType() == Observer::PageLifecycleObserverType) { | 46 LifecycleNotifier<Page, PageLifecycleObserver>::removeObserver(observer); |
| 52 RELEASE_ASSERT(m_iterating != IteratingOverPageObservers); | |
| 53 m_pageObservers.remove(static_cast<PageLifecycleObserver*>(observer)); | |
| 54 } | |
| 55 | |
| 56 LifecycleNotifier<Page>::removeObserver(observer); | |
| 57 } | 47 } |
| 58 | 48 |
| 59 void PageLifecycleNotifier::notifyPageVisibilityChanged() | 49 void PageLifecycleNotifier::notifyPageVisibilityChanged() |
| 60 { | 50 { |
| 61 TemporaryChange<IterationType> scope(m_iterating, IteratingOverPageObservers
); | 51 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); |
| 62 for (PageLifecycleObserver* pageObserver : m_pageObservers) | 52 for (PageLifecycleObserver* observer : m_observers) |
| 63 pageObserver->pageVisibilityChanged(); | 53 observer->pageVisibilityChanged(); |
| 64 } | 54 } |
| 65 | 55 |
| 66 void PageLifecycleNotifier::notifyDidCommitLoad(LocalFrame* frame) | 56 void PageLifecycleNotifier::notifyDidCommitLoad(LocalFrame* frame) |
| 67 { | 57 { |
| 68 TemporaryChange<IterationType> scope(m_iterating, IteratingOverPageObservers
); | 58 TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll); |
| 69 for (PageLifecycleObserver* pageObserver : m_pageObservers) | 59 for (PageLifecycleObserver* observer : m_observers) |
| 70 pageObserver->didCommitLoad(frame); | 60 observer->didCommitLoad(frame); |
| 71 } | 61 } |
| 72 | 62 |
| 73 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |