#ifndef ScheduledAction_h
#define ScheduledAction_h
#include "JSDOMBinding.h"
#include <heap/Strong.h>
#include <heap/StrongInlines.h>
#include <memory>
#include <runtime/JSCell.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace JSC {
class JSGlobalObject;
}
namespace WebCore {
class Document;
class ContentSecurityPolicy;
class ScriptExecutionContext;
class WorkerGlobalScope;
class ScheduledAction {
WTF_MAKE_NONCOPYABLE(ScheduledAction); WTF_MAKE_FAST_ALLOCATED;
public:
static std::unique_ptr<ScheduledAction> create(JSC::ExecState*, DOMWrapperWorld& isolatedWorld, ContentSecurityPolicy*);
void execute(ScriptExecutionContext&);
private:
ScheduledAction(JSC::ExecState*, JSC::JSValue function, DOMWrapperWorld& isolatedWorld);
ScheduledAction(const String& code, DOMWrapperWorld& isolatedWorld)
: m_function(isolatedWorld.vm())
, m_code(code)
, m_isolatedWorld(&isolatedWorld)
{
}
void executeFunctionInContext(JSC::JSGlobalObject*, JSC::JSValue thisValue, ScriptExecutionContext&);
void execute(Document&);
void execute(WorkerGlobalScope&);
JSC::Strong<JSC::Unknown> m_function;
Vector<JSC::Strong<JSC::Unknown>> m_args;
String m_code;
RefPtr<DOMWrapperWorld> m_isolatedWorld;
};
}
#endif // ScheduledAction_h