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

Unified Diff: Source/core/dom/DocumentLifecycleNotifier.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 | « no previous file | Source/core/frame/DOMWindowLifecycleNotifier.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/DocumentLifecycleNotifier.cpp
diff --git a/Source/core/dom/DocumentLifecycleNotifier.cpp b/Source/core/dom/DocumentLifecycleNotifier.cpp
index 12fc7db522b4032cb733342f5e647fd83d44e211..e9b8cd042145c6f8abbc3c6176493f1b4c09d342 100644
--- a/Source/core/dom/DocumentLifecycleNotifier.cpp
+++ b/Source/core/dom/DocumentLifecycleNotifier.cpp
@@ -34,16 +34,39 @@ namespace blink {
void DocumentLifecycleNotifier::notifyDocumentWasDetached()
{
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<DocumentLifecycleObserver>> snapshotOfObservers;
+ copyToVector(m_observers, snapshotOfObservers);
+ for (DocumentLifecycleObserver* observer : snapshotOfObservers) {
+ if (m_observers.contains(observer))
+ observer->documentWasDetached();
+ }
+#else
for (DocumentLifecycleObserver* observer : m_observers)
observer->documentWasDetached();
+#endif
}
#if !ENABLE(OILPAN)
void DocumentLifecycleNotifier::notifyDocumentWasDisposed()
{
TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
- for (DocumentLifecycleObserver* observer : m_observers)
- observer->documentWasDisposed();
+ // 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<DocumentLifecycleObserver>> snapshotOfObservers;
+ copyToVector(m_observers, snapshotOfObservers);
+ for (DocumentLifecycleObserver* observer : snapshotOfObservers) {
+ if (m_observers.contains(observer))
+ observer->documentWasDisposed();
+ }
}
#endif
« no previous file with comments | « no previous file | Source/core/frame/DOMWindowLifecycleNotifier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698