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

Unified Diff: Source/core/frame/DOMWindowLifecycleNotifier.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/dom/DocumentLifecycleNotifier.cpp ('k') | Source/core/frame/LocalFrameLifecycleNotifier.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/DOMWindowLifecycleNotifier.cpp
diff --git a/Source/core/frame/DOMWindowLifecycleNotifier.cpp b/Source/core/frame/DOMWindowLifecycleNotifier.cpp
index 0bf68af63befb4c417e068c7c83e482e62bd660b..5f525b66cd0d3fd739d7eac96a3b0ade3423d5cf 100644
--- a/Source/core/frame/DOMWindowLifecycleNotifier.cpp
+++ b/Source/core/frame/DOMWindowLifecycleNotifier.cpp
@@ -34,22 +34,64 @@ namespace blink {
void DOMWindowLifecycleNotifier::notifyAddEventListener(LocalDOMWindow* window, const AtomicString& eventType)
{
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<DOMWindowLifecycleObserver>> snapshotOfObservers;
+ copyToVector(m_observers, snapshotOfObservers);
+ for (DOMWindowLifecycleObserver* observer : snapshotOfObservers) {
+ if (m_observers.contains(observer))
+ observer->didAddEventListener(window, eventType);
+ }
+#else
for (DOMWindowLifecycleObserver* observer : m_observers)
observer->didAddEventListener(window, eventType);
+#endif
}
void DOMWindowLifecycleNotifier::notifyRemoveEventListener(LocalDOMWindow* window, const AtomicString& eventType)
{
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<DOMWindowLifecycleObserver>> snapshotOfObservers;
+ copyToVector(m_observers, snapshotOfObservers);
+ for (DOMWindowLifecycleObserver* observer : snapshotOfObservers) {
+ if (m_observers.contains(observer))
+ observer->didRemoveEventListener(window, eventType);
+ }
+#else
for (DOMWindowLifecycleObserver* observer : m_observers)
observer->didRemoveEventListener(window, eventType);
+#endif
}
void DOMWindowLifecycleNotifier::notifyRemoveAllEventListeners(LocalDOMWindow* window)
{
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<DOMWindowLifecycleObserver>> snapshotOfObservers;
+ copyToVector(m_observers, snapshotOfObservers);
+ for (DOMWindowLifecycleObserver* observer : snapshotOfObservers) {
+ if (m_observers.contains(observer))
+ observer->didRemoveAllEventListeners(window);
+ }
+#else
for (DOMWindowLifecycleObserver* observer : m_observers)
observer->didRemoveAllEventListeners(window);
+#endif
}
} // namespace blink
« no previous file with comments | « Source/core/dom/DocumentLifecycleNotifier.cpp ('k') | Source/core/frame/LocalFrameLifecycleNotifier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698