#pragma once
#include <JavaScriptCore/Strong.h>
#include <JavaScriptCore/StrongInlines.h>
#include <memory>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace JSC {
class JSGlobalObject;
}
namespace WebCore {
class DOMWrapperWorld;
class Document;
class ScriptExecutionContext;
class WorkerGlobalScope;
class ScheduledAction {
WTF_MAKE_FAST_ALLOCATED;
public:
static std::unique_ptr<ScheduledAction> create(DOMWrapperWorld&, JSC::Strong<JSC::Unknown>&&);
static std::unique_ptr<ScheduledAction> create(DOMWrapperWorld&, String&&);
~ScheduledAction();
void addArguments(Vector<JSC::Strong<JSC::Unknown>>&&);
enum class Type { Code, Function };
Type type() const;
void execute(ScriptExecutionContext&);
private:
ScheduledAction(DOMWrapperWorld&, JSC::Strong<JSC::Unknown>&&);
ScheduledAction(DOMWrapperWorld&, String&&);
void executeFunctionInContext(JSC::JSGlobalObject*, JSC::JSValue thisValue, ScriptExecutionContext&);
void execute(Document&);
void execute(WorkerGlobalScope&);
Ref<DOMWrapperWorld> m_isolatedWorld;
JSC::Strong<JSC::Unknown> m_function;
Vector<JSC::Strong<JSC::Unknown>> m_arguments;
String m_code;
};
}