diff options
Diffstat (limited to 'webkit/port/bindings/v8/WorkerScriptController.cpp')
-rw-r--r-- | webkit/port/bindings/v8/WorkerScriptController.cpp | 62 |
1 files changed, 7 insertions, 55 deletions
diff --git a/webkit/port/bindings/v8/WorkerScriptController.cpp b/webkit/port/bindings/v8/WorkerScriptController.cpp index 967a2d2..a897bb2 100644 --- a/webkit/port/bindings/v8/WorkerScriptController.cpp +++ b/webkit/port/bindings/v8/WorkerScriptController.cpp @@ -35,52 +35,23 @@ #include "ScriptSourceCode.h" #include "ScriptValue.h" -#include "v8_proxy.h" #include "DOMTimer.h" #include "WorkerContext.h" +#include "WorkerContextExecutionProxy.h" #include "WorkerMessagingProxy.h" #include "WorkerThread.h" namespace WebCore { -// TODO(dimich): Move these stubs once they're implemented. -int DOMTimer::install(ScriptExecutionContext*, ScheduledAction*, int timeout, - bool singleShot) { - return 0; -} -void DOMTimer::removeById(ScriptExecutionContext*, int timeoutId) { -} - WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) : m_workerContext(workerContext) + , m_proxy(new WorkerContextExecutionProxy(workerContext)) , m_executionForbidden(false) { } WorkerScriptController::~WorkerScriptController() { - Dispose(); -} - -void WorkerScriptController::Dispose() -{ - if (!m_context.IsEmpty()) { - m_context.Dispose(); - m_context.Clear(); - } -} - -void WorkerScriptController::InitContextIfNeeded() -{ - // Bail out if the context has already been initialized. - if (!m_context.IsEmpty()) - return; - - // Create a new environment - v8::Persistent<v8::ObjectTemplate> global_template; - m_context = v8::Context::New(NULL, global_template); - - // TODO (jianli): to initialize the context. } ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode) @@ -91,32 +62,15 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode) return ScriptValue(); } - v8::Local<v8::Value> result; - { - v8::Locker locker; - v8::HandleScope hs; - - InitContextIfNeeded(); - v8::Context::Scope scope(m_context); - - v8::Local<v8::String> code = v8ExternalString(sourceCode.source()); - v8::Handle<v8::Script> script = - V8Proxy::CompileScript(code, - sourceCode.url().string(), - sourceCode.startLine() - 1); - - // TODO (jianli): handle infinite recursion. - - result = script->Run(); - - if (V8Proxy::HandleOutOfMemory()) - return ScriptValue(); - } + v8::Local<v8::Value> result = + m_proxy->Evaluate(sourceCode.source(), + sourceCode.url().string(), + sourceCode.startLine() - 1); m_workerContext->thread()->messagingProxy()-> reportWorkerThreadActivity(m_workerContext->hasPendingActivity()); - return ScriptValue(result); + return ScriptValue(); } void WorkerScriptController::forbidExecution() @@ -124,8 +78,6 @@ void WorkerScriptController::forbidExecution() // This function is called from another thread. MutexLocker lock(m_sharedDataMutex); m_executionForbidden = true; - - Dispose(); } } // namespace WebCore |