WorkerScriptController.h [plain text]
#pragma once
#include <JavaScriptCore/Debugger.h>
#include <JavaScriptCore/JSRunLoopTimer.h>
#include <JavaScriptCore/Strong.h>
#include <wtf/Forward.h>
#include <wtf/Lock.h>
#include <wtf/NakedPtr.h>
namespace JSC {
class VM;
}
namespace WebCore {
class JSWorkerGlobalScope;
class ScriptSourceCode;
class WorkerConsoleClient;
class WorkerGlobalScope;
class WorkerScriptController {
WTF_MAKE_NONCOPYABLE(WorkerScriptController); WTF_MAKE_FAST_ALLOCATED;
public:
WorkerScriptController(WorkerGlobalScope*);
~WorkerScriptController();
JSWorkerGlobalScope* workerGlobalScopeWrapper()
{
initScriptIfNeeded();
return m_workerGlobalScopeWrapper.get();
}
void evaluate(const ScriptSourceCode&, String* returnedExceptionMessage = nullptr);
void evaluate(const ScriptSourceCode&, NakedPtr<JSC::Exception>& returnedException, String* returnedExceptionMessage = nullptr);
void setException(JSC::Exception*);
void scheduleExecutionTermination();
bool isTerminatingExecution() const;
void forbidExecution();
bool isExecutionForbidden() const;
void disableEval(const String& errorMessage);
void disableWebAssembly(const String& errorMessage);
JSC::VM& vm() { return *m_vm; }
void releaseHeapAccess();
void acquireHeapAccess();
void addTimerSetNotification(JSC::JSRunLoopTimer::TimerNotificationCallback);
void removeTimerSetNotification(JSC::JSRunLoopTimer::TimerNotificationCallback);
void attachDebugger(JSC::Debugger*);
void detachDebugger(JSC::Debugger*);
private:
void initScriptIfNeeded()
{
if (!m_workerGlobalScopeWrapper)
initScript();
}
WEBCORE_EXPORT void initScript();
RefPtr<JSC::VM> m_vm;
WorkerGlobalScope* m_workerGlobalScope;
JSC::Strong<JSWorkerGlobalScope> m_workerGlobalScopeWrapper;
std::unique_ptr<WorkerConsoleClient> m_consoleClient;
bool m_executionForbidden { false };
bool m_isTerminatingExecution { false };
mutable Lock m_scheduledTerminationMutex;
};
}