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

Unified Diff: third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp

Issue 2109553002: Allow lazy removal of (context) lifecycle observers while stopping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | third_party/WebKit/Source/platform/LifecycleNotifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp
diff --git a/third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp b/third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp
index c089d6e5c7660d86601356cab18abd0e3a062843..bd44cef0e1ffcd94280744e349e2061c102ed347 100644
--- a/third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp
+++ b/third_party/WebKit/Source/core/dom/ContextLifecycleNotifier.cpp
@@ -64,9 +64,11 @@ void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects()
void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects()
{
- // Neither additions nor removals are allowed while iterating.
- TemporaryChange<IterationState> scope(m_iterationState, AllowingNone);
- for (ContextLifecycleObserver* observer : m_observers) {
+ // Observers may be removed, but handled after iteration has completed.
+ TemporaryChange<IterationState> scope(m_iterationState, AllowPendingRemoval);
+ ObserverSet observers;
+ m_observers.swap(observers);
+ for (ContextLifecycleObserver* observer : observers) {
if (observer->observerType() != ContextLifecycleObserver::ActiveDOMObjectType)
continue;
ActiveDOMObject* activeDOMObject = static_cast<ActiveDOMObject*>(observer);
@@ -76,10 +78,12 @@ void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects()
#endif
activeDOMObject->stop();
}
+ removePending(observers);
}
unsigned ContextLifecycleNotifier::activeDOMObjectCount() const
{
+ DCHECK(!isIteratingOverObservers());
unsigned activeDOMObjects = 0;
for (ContextLifecycleObserver* observer : m_observers) {
if (observer->observerType() != ContextLifecycleObserver::ActiveDOMObjectType)
@@ -92,6 +96,7 @@ unsigned ContextLifecycleNotifier::activeDOMObjectCount() const
#if DCHECK_IS_ON()
bool ContextLifecycleNotifier::contains(ActiveDOMObject* object) const
{
+ DCHECK(!isIteratingOverObservers());
for (ContextLifecycleObserver* observer : m_observers) {
if (observer->observerType() != ContextLifecycleObserver::ActiveDOMObjectType)
continue;
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/LifecycleNotifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698