summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/ActiveDOMObject.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/ActiveDOMObject.h')
-rw-r--r--Source/WebCore/dom/ActiveDOMObject.h60
1 files changed, 36 insertions, 24 deletions
diff --git a/Source/WebCore/dom/ActiveDOMObject.h b/Source/WebCore/dom/ActiveDOMObject.h
index 5a1f3d121..c47b1f45a 100644
--- a/Source/WebCore/dom/ActiveDOMObject.h
+++ b/Source/WebCore/dom/ActiveDOMObject.h
@@ -10,10 +10,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -24,8 +24,7 @@
*
*/
-#ifndef ActiveDOMObject_h
-#define ActiveDOMObject_h
+#pragma once
#include "ContextDestructionObserver.h"
#include <wtf/Assertions.h>
@@ -35,40 +34,46 @@ namespace WebCore {
class ActiveDOMObject : public ContextDestructionObserver {
public:
- explicit ActiveDOMObject(ScriptExecutionContext*);
-
- // suspendIfNeeded() should be called exactly once after object construction to synchronize
- // the suspend state with that in ScriptExecutionContext.
+ // The suspendIfNeeded must be called exactly once after object construction to update
+ // the suspended state to match that of the ScriptExecutionContext.
void suspendIfNeeded();
-#if !ASSERT_DISABLED
- bool suspendIfNeededCalled() const { return m_suspendIfNeededCalled; }
-#endif
+ void assertSuspendIfNeededWasCalled() const;
virtual bool hasPendingActivity() const;
- // canSuspend() is used by the caller if there is a choice between suspending and stopping.
- // For example, a page won't be suspended and placed in the back/forward cache if it has
- // the objects that can not be suspended.
- // However, 'suspend' can be called even if canSuspend() would return 'false'. That
- // happens in step-by-step JS debugging for example - in this case it would be incorrect
- // to stop the object. Exact semantics of suspend is up to the object then.
+ // The canSuspendForDocumentSuspension() function is used by the caller if there is a choice between suspending
+ // and stopping. For example, a page won't be suspended and placed in the back/forward
+ // cache if it contains any objects that cannot be suspended.
+
+ // However, the suspend function will sometimes be called even if canSuspendForDocumentSuspension() returns false.
+ // That happens in step-by-step JS debugging for example - in this case it would be incorrect
+ // to stop the object. Exact semantics of suspend is up to the object in cases like that.
+
enum ReasonForSuspension {
JavaScriptDebuggerPaused,
WillDeferLoading,
- DocumentWillBecomeInactive,
+ PageCache,
PageWillBeSuspended,
- DocumentWillBePaused
};
- virtual bool canSuspend() const;
+
+ virtual const char* activeDOMObjectName() const = 0;
+
+ // These three functions must not have a side effect of creating or destroying
+ // any ActiveDOMObject. That means they must not result in calls to arbitrary JavaScript.
+ virtual bool canSuspendForDocumentSuspension() const = 0; // Returning false in canSuspendForDocumentSuspension() will prevent the page from entering the PageCache.
virtual void suspend(ReasonForSuspension);
virtual void resume();
+
+ // This function must not have a side effect of creating an ActiveDOMObject.
+ // That means it must not result in calls to arbitrary JavaScript.
+ // It can, however, have a side effect of deleting an ActiveDOMObject.
virtual void stop();
template<class T> void setPendingActivity(T* thisObject)
{
ASSERT(thisObject == this);
thisObject->ref();
- m_pendingActivityCount++;
+ ++m_pendingActivityCount;
}
template<class T> void unsetPendingActivity(T* thisObject)
@@ -79,15 +84,22 @@ public:
}
protected:
+ explicit ActiveDOMObject(ScriptExecutionContext*);
virtual ~ActiveDOMObject();
private:
unsigned m_pendingActivityCount;
#if !ASSERT_DISABLED
- bool m_suspendIfNeededCalled;
+ bool m_suspendIfNeededWasCalled;
#endif
};
-} // namespace WebCore
+#if ASSERT_DISABLED
+
+inline void ActiveDOMObject::assertSuspendIfNeededWasCalled() const
+{
+}
-#endif // ActiveDOMObject_h
+#endif
+
+} // namespace WebCore