WorkerScriptController.cpp [plain text]
#include "config.h"
#if ENABLE(WORKERS)
#include "WorkerScriptController.h"
#include <v8.h>
#include "ScriptSourceCode.h"
#include "ScriptValue.h"
#include "DOMTimer.h"
#include "V8DOMMap.h"
#include "V8Proxy.h"
#include "WorkerContext.h"
#include "WorkerContextExecutionProxy.h"
#include "WorkerObjectProxy.h"
#include "WorkerThread.h"
namespace WebCore {
WorkerScriptController::WorkerScriptController(WorkerContext* workerContext)
: m_workerContext(workerContext)
, m_proxy(new WorkerContextExecutionProxy(workerContext))
, m_executionForbidden(false)
{
}
WorkerScriptController::~WorkerScriptController()
{
removeAllDOMObjectsInCurrentThread();
}
ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
{
{
MutexLocker lock(m_sharedDataMutex);
if (m_executionForbidden)
return ScriptValue();
}
v8::Local<v8::Value> result = m_proxy->evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startLine() - 1);
m_workerContext->thread()->workerObjectProxy().reportPendingActivity(m_workerContext->hasPendingActivity());
return ScriptValue();
}
ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, ScriptValue* exception)
{
v8::TryCatch exceptionCatcher;
ScriptValue result = evaluate(sourceCode);
if (exceptionCatcher.HasCaught()) {
*exception = ScriptValue(exceptionCatcher.Exception());
throwError(exceptionCatcher.Exception());
return ScriptValue();
} else
return result;
}
void WorkerScriptController::forbidExecution()
{
MutexLocker lock(m_sharedDataMutex);
m_executionForbidden = true;
}
void WorkerScriptController::setException(ScriptValue )
{
notImplemented();
}
}
#endif // ENABLE(WORKERS)