summaryrefslogtreecommitdiff
path: root/Source/WebCore/bindings/js/ScheduledAction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/bindings/js/ScheduledAction.cpp')
-rw-r--r--Source/WebCore/bindings/js/ScheduledAction.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/Source/WebCore/bindings/js/ScheduledAction.cpp b/Source/WebCore/bindings/js/ScheduledAction.cpp
index 9173edd49..93332666b 100644
--- a/Source/WebCore/bindings/js/ScheduledAction.cpp
+++ b/Source/WebCore/bindings/js/ScheduledAction.cpp
@@ -29,7 +29,7 @@
#include "Document.h"
#include "Frame.h"
#include "FrameLoader.h"
-#include "JSDOMBinding.h"
+#include "JSDOMExceptionHandling.h"
#include "JSDOMWindow.h"
#include "JSMainThreadExecState.h"
#include "JSMainThreadExecStateInstrumentation.h"
@@ -39,27 +39,28 @@
#include "ScriptSourceCode.h"
#include "WorkerGlobalScope.h"
#include "WorkerThread.h"
-#include <bindings/ScriptValue.h>
#include <runtime/JSLock.h>
using namespace JSC;
namespace WebCore {
-PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperWorld& isolatedWorld, ContentSecurityPolicy* policy)
+std::unique_ptr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperWorld& isolatedWorld, ContentSecurityPolicy* policy)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
JSValue v = exec->argument(0);
CallData callData;
- if (getCallData(v, callData) == CallTypeNone) {
+ if (getCallData(v, callData) == CallType::None) {
if (policy && !policy->allowEval(exec))
return nullptr;
- String string = v.toString(exec)->value(exec);
- if (exec->hadException())
- return nullptr;
- return adoptPtr(new ScheduledAction(string, isolatedWorld));
+ String string = v.toWTFString(exec);
+ RETURN_IF_EXCEPTION(scope, nullptr);
+ return std::unique_ptr<ScheduledAction>(new ScheduledAction(string, isolatedWorld));
}
- return adoptPtr(new ScheduledAction(exec, v, isolatedWorld));
+ return std::unique_ptr<ScheduledAction>(new ScheduledAction(exec, v, isolatedWorld));
}
ScheduledAction::ScheduledAction(ExecState* exec, JSValue function, DOMWrapperWorld& isolatedWorld)
@@ -72,24 +73,22 @@ ScheduledAction::ScheduledAction(ExecState* exec, JSValue function, DOMWrapperWo
m_args.append(Strong<JSC::Unknown>(exec->vm(), exec->uncheckedArgument(i)));
}
-void ScheduledAction::execute(ScriptExecutionContext* context)
+void ScheduledAction::execute(ScriptExecutionContext& context)
{
- if (context->isDocument())
- execute(toDocument(context));
- else {
- ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope());
- execute(static_cast<WorkerGlobalScope*>(context));
- }
+ if (is<Document>(context))
+ execute(downcast<Document>(context));
+ else
+ execute(downcast<WorkerGlobalScope>(context));
}
-void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSValue thisValue, ScriptExecutionContext* context)
+void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSValue thisValue, ScriptExecutionContext& context)
{
ASSERT(m_function);
- JSLockHolder lock(context->vm());
+ JSLockHolder lock(context.vm());
CallData callData;
CallType callType = getCallData(m_function.get(), callData);
- if (callType == CallTypeNone)
+ if (callType == CallType::None)
return;
ExecState* exec = globalObject->globalExec();
@@ -99,26 +98,27 @@ void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSV
for (size_t i = 0; i < size; ++i)
args.append(m_args[i].get());
- InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData);
+ InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(&context, callType, callData);
- if (context->isDocument())
- JSMainThreadExecState::call(exec, m_function.get(), callType, callData, thisValue, args);
+ NakedPtr<JSC::Exception> exception;
+ if (is<Document>(context))
+ JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, m_function.get(), callType, callData, thisValue, args, exception);
else
- JSC::call(exec, m_function.get(), callType, callData, thisValue, args);
+ JSC::profiledCall(exec, JSC::ProfilingReason::Other, m_function.get(), callType, callData, thisValue, args, exception);
- InspectorInstrumentation::didCallFunction(cookie);
+ InspectorInstrumentation::didCallFunction(cookie, &context);
- if (exec->hadException())
- reportCurrentException(exec);
+ if (exception)
+ reportException(exec, exception);
}
-void ScheduledAction::execute(Document* document)
+void ScheduledAction::execute(Document& document)
{
- JSDOMWindow* window = toJSDOMWindow(document->frame(), *m_isolatedWorld);
+ JSDOMWindow* window = toJSDOMWindow(document.frame(), *m_isolatedWorld);
if (!window)
return;
- RefPtr<Frame> frame = window->impl().frame();
+ RefPtr<Frame> frame = window->wrapped().frame();
if (!frame || !frame->script().canExecuteScripts(AboutToExecuteScript))
return;
@@ -128,18 +128,18 @@ void ScheduledAction::execute(Document* document)
frame->script().executeScriptInWorld(*m_isolatedWorld, m_code);
}
-void ScheduledAction::execute(WorkerGlobalScope* workerGlobalScope)
+void ScheduledAction::execute(WorkerGlobalScope& workerGlobalScope)
{
// In a Worker, the execution should always happen on a worker thread.
- ASSERT(workerGlobalScope->thread()->threadID() == currentThread());
+ ASSERT(workerGlobalScope.thread().threadID() == currentThread());
- WorkerScriptController* scriptController = workerGlobalScope->script();
+ WorkerScriptController* scriptController = workerGlobalScope.script();
if (m_function) {
JSWorkerGlobalScope* contextWrapper = scriptController->workerGlobalScopeWrapper();
executeFunctionInContext(contextWrapper, contextWrapper, workerGlobalScope);
} else {
- ScriptSourceCode code(m_code, workerGlobalScope->url());
+ ScriptSourceCode code(m_code, workerGlobalScope.url());
scriptController->evaluate(code);
}
}