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

Unified Diff: Source/platform/LifecycleNotifier.h

Issue 1008113002: Remove LifecycleNotifier<>::m_context. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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/platform/LifecycleContextTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/LifecycleNotifier.h
diff --git a/Source/platform/LifecycleNotifier.h b/Source/platform/LifecycleNotifier.h
index c256694dfba92484ce5d006beacc332a09a86d42..f465555b68199f20cde0ffa1a8b5039b385257bf 100644
--- a/Source/platform/LifecycleNotifier.h
+++ b/Source/platform/LifecycleNotifier.h
@@ -27,9 +27,8 @@
#ifndef LifecycleNotifier_h
#define LifecycleNotifier_h
-#include "platform/LifecycleObserver.h"
+#include "platform/heap/Handle.h"
#include "wtf/HashSet.h"
-#include "wtf/PassOwnPtr.h"
#include "wtf/TemporaryChange.h"
namespace blink {
@@ -37,10 +36,7 @@ namespace blink {
template<typename T, typename Observer>
class LifecycleNotifier {
public:
- typedef T Context;
-
virtual ~LifecycleNotifier();
- virtual bool isContextThread() const { return true; }
void addObserver(Observer*);
void removeObserver(Observer*);
@@ -48,8 +44,8 @@ public:
// notifyContextDestroyed() should be explicitly dispatched from an
// observed context to notify observers that contextDestroyed().
//
- // When contextDestroyed() is called, m_context is still
- // valid and safe to use m_context during the notification.
+ // When contextDestroyed() is called, the observer's lifecycleContext()
+ // is still valid and safe to use during the notification.
virtual void notifyContextDestroyed();
DEFINE_INLINE_VIRTUAL_TRACE() { }
@@ -57,15 +53,12 @@ public:
bool isIteratingOverObservers() const { return m_iterating != IteratingNone; }
protected:
- explicit LifecycleNotifier(Context* context)
+ LifecycleNotifier()
: m_iterating(IteratingNone)
- , m_context(context)
, m_didCallContextDestroyed(false)
{
}
- Context* context() const { return m_context; }
-
enum IterationType {
IteratingNone,
IteratingOverAll,
@@ -79,8 +72,11 @@ protected:
ObserverSet m_observers;
+#if ENABLE(ASSERT)
+ T* context() { return static_cast<T*>(this); }
+#endif
+
private:
- Context* m_context;
bool m_didCallContextDestroyed;
};
@@ -93,7 +89,7 @@ inline LifecycleNotifier<T, Observer>::~LifecycleNotifier()
#if !ENABLE(OILPAN)
TemporaryChange<IterationType> scope(m_iterating, IteratingOverAll);
for (Observer* observer : m_observers) {
- ASSERT(observer->lifecycleContext() == m_context);
+ ASSERT(observer->lifecycleContext() == context());
observer->clearLifecycleContext();
}
#endif
@@ -116,7 +112,7 @@ inline void LifecycleNotifier<T, Observer>::notifyContextDestroyed()
// a HeapHashSet<WeakMember<Observers>>. (i.e., we can just iterate
// m_observers without taking a snapshot).
if (m_observers.contains(observer)) {
- ASSERT(observer->lifecycleContext() == m_context);
+ ASSERT(observer->lifecycleContext() == context());
observer->contextDestroyed();
}
}
« no previous file with comments | « Source/platform/LifecycleContextTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698