#include "core/dom/ContextLifecycleObserver.h"
#include "wtf/Assertions.h"
-#include "wtf/Forward.h"
-namespace WebCore {
+namespace blink {
class ActiveDOMObject : public ContextLifecycleObserver {
public:
// suspendIfNeeded() should be called exactly once after object construction to synchronize
// the suspend state with that in ExecutionContext.
void suspendIfNeeded();
-#if !ASSERT_DISABLED
+#if ENABLE(ASSERT)
bool suspendIfNeededCalled() const { return m_suspendIfNeededCalled; }
#endif
+ // Should return true if there's any pending asynchronous activity, and so
+ // this object must not be garbage collected.
virtual bool hasPendingActivity() const;
+ // These methods have an empty default implementation so that subclasses
+ // which don't need special treatment can skip implementation.
virtual void suspend();
virtual void resume();
virtual void stop();
- template<class T> void setPendingActivity(T* thisObject)
- {
- ASSERT(thisObject == this);
- thisObject->ref();
- m_pendingActivityCount++;
- }
-
- template<class T> void unsetPendingActivity(T* thisObject)
- {
- ASSERT(m_pendingActivityCount > 0);
- --m_pendingActivityCount;
- thisObject->deref();
- }
+ void didMoveToNewExecutionContext(ExecutionContext*);
protected:
virtual ~ActiveDOMObject();
private:
- unsigned m_pendingActivityCount;
-#if !ASSERT_DISABLED
+#if ENABLE(ASSERT)
bool m_suspendIfNeededCalled;
#endif
};
-} // namespace WebCore
+} // namespace blink
#endif // ActiveDOMObject_h