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

Unified Diff: Source/core/frame/LocalFrameLifecycleNotifier.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/DOMWindowLifecycleNotifier.cpp ('k') | Source/core/page/PageLifecycleNotifier.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/LocalFrameLifecycleNotifier.cpp
diff --git a/Source/core/frame/LocalFrameLifecycleNotifier.cpp b/Source/core/frame/LocalFrameLifecycleNotifier.cpp
index 434cf8bc2c36ffdc0ddd766b23b124726e87aeca..828226710e1ae5ba7d5b04073d453d4b1c2eb811 100644
--- a/Source/core/frame/LocalFrameLifecycleNotifier.cpp
+++ b/Source/core/frame/LocalFrameLifecycleNotifier.cpp
@@ -12,8 +12,22 @@ namespace blink {
void LocalFrameLifecycleNotifier::notifyWillDetachFrameHost()
{
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<LocalFrameLifecycleObserver>> snapshotOfObservers;
+ copyToVector(m_observers, snapshotOfObservers);
+ for (LocalFrameLifecycleObserver* observer : snapshotOfObservers) {
+ if (m_observers.contains(observer))
+ observer->willDetachFrameHost();
+ }
+#else
for (LocalFrameLifecycleObserver* observer : m_observers)
observer->willDetachFrameHost();
+#endif
}
} // namespace blink
« no previous file with comments | « Source/core/frame/DOMWindowLifecycleNotifier.cpp ('k') | Source/core/page/PageLifecycleNotifier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698