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

Unified Diff: third_party/WebKit/Source/platform/LifecycleNotifier.h

Issue 2045703004: Simplify contextDestroyed() notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: eagerly clear observers 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/LifecycleNotifier.h
diff --git a/third_party/WebKit/Source/platform/LifecycleNotifier.h b/third_party/WebKit/Source/platform/LifecycleNotifier.h
index 9c53a533a6a4e819b9b4b6ed09d42480cb7b2718..27cbdc52b1a7c276c92614f318008bda2dd8de17 100644
--- a/third_party/WebKit/Source/platform/LifecycleNotifier.h
+++ b/third_party/WebKit/Source/platform/LifecycleNotifier.h
@@ -58,7 +58,6 @@ public:
protected:
LifecycleNotifier()
: m_iterating(IteratingNone)
- , m_didCallContextDestroyed(false)
{
}
@@ -77,37 +76,25 @@ protected:
#if DCHECK_IS_ON()
T* context() { return static_cast<T*>(this); }
#endif
-
-private:
- bool m_didCallContextDestroyed;
};
template<typename T, typename Observer>
inline LifecycleNotifier<T, Observer>::~LifecycleNotifier()
{
// FIXME: Enable the following ASSERT. Also see a FIXME in Document::detach().
- // ASSERT(!m_observers.size() || m_didCallContextDestroyed);
+ // ASSERT(!m_observers.size());
}
template<typename T, typename Observer>
inline void LifecycleNotifier<T, Observer>::notifyContextDestroyed()
{
- // Don't notify contextDestroyed() twice.
- if (m_didCallContextDestroyed)
- return;
-
TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
- Vector<UntracedMember<Observer>> snapshotOfObservers;
- copyToVector(m_observers, snapshotOfObservers);
- for (Observer* observer : snapshotOfObservers) {
- if (!m_observers.contains(observer))
- continue;
-
+ ObserverSet observers;
+ m_observers.swap(observers);
+ for (Observer* observer : observers) {
ASSERT(observer->lifecycleContext() == context());
observer->contextDestroyed();
}
-
- m_didCallContextDestroyed = true;
}
template<typename T, typename Observer>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698