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

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

Issue 1214963002: Oilpan: support observer retirement during lifetime notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « Source/core/frame/LocalFrameLifecycleNotifier.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/PageLifecycleNotifier.cpp
diff --git a/Source/core/page/PageLifecycleNotifier.cpp b/Source/core/page/PageLifecycleNotifier.cpp
index 2a6f3869481dc57f8840bc785acf5f467f7ead2a..bffda9050ecfd0c5264725a605a2bad46d0fb014 100644
--- a/Source/core/page/PageLifecycleNotifier.cpp
+++ b/Source/core/page/PageLifecycleNotifier.cpp
@@ -34,15 +34,43 @@ namespace blink {
void PageLifecycleNotifier::notifyPageVisibilityChanged()
{
TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
+#if !ENABLE(OILPAN)
+ // Notifications perform unknown amounts of heap allocations,
+ // which might trigger (conservative) GCs. This will flush out
+ // dead observers, causing the _non-heap_ set be updated. Snapshot
+ // the observers and explicitly check if they're still alive before
+ // notifying.
+ Vector<RawPtr<PageLifecycleObserver>> snapshotOfObservers;
+ copyToVector(m_observers, snapshotOfObservers);
+ for (PageLifecycleObserver* observer : snapshotOfObservers) {
+ if (m_observers.contains(observer))
+ observer->pageVisibilityChanged();
+ }
+#else
for (PageLifecycleObserver* observer : m_observers)
observer->pageVisibilityChanged();
+#endif
}
void PageLifecycleNotifier::notifyDidCommitLoad(LocalFrame* frame)
{
TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
+#if !ENABLE(OILPAN)
+ // Notifications perform unknown amounts of heap allocations,
+ // which might trigger (conservative) GCs. This will flush out
+ // dead observers, causing the _non-heap_ set be updated. Snapshot
+ // the observers and explicitly check if they're still alive before
+ // notifying.
+ Vector<RawPtr<PageLifecycleObserver>> snapshotOfObservers;
+ copyToVector(m_observers, snapshotOfObservers);
+ for (PageLifecycleObserver* observer : snapshotOfObservers) {
+ if (m_observers.contains(observer))
+ observer->didCommitLoad(frame);
+ }
+#else
for (PageLifecycleObserver* observer : m_observers)
observer->didCommitLoad(frame);
+#endif
}
} // namespace blink
« no previous file with comments | « Source/core/frame/LocalFrameLifecycleNotifier.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698