diff options
Diffstat (limited to 'WebCore/bindings/v8/WorkerScriptController.cpp')
-rw-r--r-- | WebCore/bindings/v8/WorkerScriptController.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/WebCore/bindings/v8/WorkerScriptController.cpp b/WebCore/bindings/v8/WorkerScriptController.cpp index f2311bf..7db0d8d 100644 --- a/WebCore/bindings/v8/WorkerScriptController.cpp +++ b/WebCore/bindings/v8/WorkerScriptController.cpp @@ -41,6 +41,7 @@ #include "DOMTimer.h" #include "V8DOMMap.h" #include "V8Proxy.h" +#include "V8WorkerContext.h" #include "WorkerContext.h" #include "WorkerContextExecutionProxy.h" #include "WorkerObjectProxy.h" @@ -85,11 +86,13 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, return result; } -void WorkerScriptController::forbidExecution() +void WorkerScriptController::forbidExecution(ForbidExecutionOption option) { - // This function is called from another thread. + // This function may be called from another thread. MutexLocker lock(m_sharedDataMutex); m_executionForbidden = true; + if (option == TerminateRunningScript) + v8::V8::TerminateExecution(); } void WorkerScriptController::setException(ScriptValue exception) @@ -97,6 +100,21 @@ void WorkerScriptController::setException(ScriptValue exception) throwError(*exception.v8Value()); } +WorkerScriptController* WorkerScriptController::controllerForContext() +{ + // Happens on frame destruction, check otherwise GetCurrent() will crash. + if (!v8::Context::InContext()) + return 0; + v8::Handle<v8::Context> context = v8::Context::GetCurrent(); + v8::Handle<v8::Object> global = context->Global(); + global = V8DOMWrapper::lookupDOMWrapper(V8WorkerContext::GetTemplate(), global); + // Return 0 if the current executing context is not the worker context. + if (global.IsEmpty()) + return 0; + WorkerContext* workerContext = V8WorkerContext::toNative(global); + return workerContext->script(); +} + } // namespace WebCore #endif // ENABLE(WORKERS) |