ActiveDOMObject.cpp [plain text]
#include "config.h"
#include "ActiveDOMObject.h"
#include "Document.h"
#include "ScriptExecutionContext.h"
namespace WebCore {
ActiveDOMObject::ActiveDOMObject(ScriptExecutionContext* scriptExecutionContext)
: ContextDestructionObserver(scriptExecutionContext)
, m_pendingActivityCount(0)
#if !ASSERT_DISABLED
, m_suspendIfNeededWasCalled(false)
#endif
{
ASSERT(!is<Document>(m_scriptExecutionContext) || &downcast<Document>(m_scriptExecutionContext)->contextDocument() == downcast<Document>(m_scriptExecutionContext));
if (!m_scriptExecutionContext)
return;
ASSERT(m_scriptExecutionContext->isContextThread());
m_scriptExecutionContext->didCreateActiveDOMObject(*this);
}
ActiveDOMObject::~ActiveDOMObject()
{
ASSERT(canAccessThreadLocalDataForThread(m_creationThread));
if (!m_scriptExecutionContext)
return;
ASSERT(m_suspendIfNeededWasCalled);
ASSERT(m_scriptExecutionContext->isContextThread());
m_scriptExecutionContext->willDestroyActiveDOMObject(*this);
}
void ActiveDOMObject::suspendIfNeeded()
{
#if !ASSERT_DISABLED
ASSERT(!m_suspendIfNeededWasCalled);
m_suspendIfNeededWasCalled = true;
#endif
if (!m_scriptExecutionContext)
return;
m_scriptExecutionContext->suspendActiveDOMObjectIfNeeded(*this);
}
#if !ASSERT_DISABLED
void ActiveDOMObject::assertSuspendIfNeededWasCalled() const
{
ASSERT(m_suspendIfNeededWasCalled);
}
#endif
bool ActiveDOMObject::hasPendingActivity() const
{
return m_pendingActivityCount;
}
bool ActiveDOMObject::canSuspendForDocumentSuspension() const
{
return false;
}
void ActiveDOMObject::suspend(ReasonForSuspension)
{
}
void ActiveDOMObject::resume()
{
}
void ActiveDOMObject::stop()
{
}
bool ActiveDOMObject::isContextStopped() const
{
return !scriptExecutionContext() || scriptExecutionContext()->activeDOMObjectsAreStopped();
}
}