summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/js/WorkerScriptController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/js/WorkerScriptController.cpp')
-rw-r--r--WebCore/bindings/js/WorkerScriptController.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/WebCore/bindings/js/WorkerScriptController.cpp b/WebCore/bindings/js/WorkerScriptController.cpp
index bcf107b..3590dad 100644
--- a/WebCore/bindings/js/WorkerScriptController.cpp
+++ b/WebCore/bindings/js/WorkerScriptController.cpp
@@ -31,7 +31,8 @@
#include "WorkerScriptController.h"
#include "JSDOMBinding.h"
-#include "JSWorkerContext.h"
+#include "JSDedicatedWorkerContext.h"
+#include "JSSharedWorkerContext.h"
#include "ScriptSourceCode.h"
#include "ScriptValue.h"
#include "WorkerContext.h"
@@ -66,16 +67,30 @@ void WorkerScriptController::initScript()
{
ASSERT(!m_workerContextWrapper);
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
// Explicitly protect the global object's prototype so it isn't collected
// when we allocate the global object. (Once the global object is fully
// constructed, it can mark its own prototype.)
- RefPtr<Structure> prototypeStructure = JSWorkerContextPrototype::createStructure(jsNull());
- ProtectedPtr<JSWorkerContextPrototype> prototype = new (m_globalData.get()) JSWorkerContextPrototype(prototypeStructure.release());
-
- RefPtr<Structure> structure = JSWorkerContext::createStructure(prototype);
- m_workerContextWrapper = new (m_globalData.get()) JSWorkerContext(structure.release(), m_workerContext);
+ RefPtr<Structure> workerContextPrototypeStructure = JSWorkerContextPrototype::createStructure(jsNull());
+ ProtectedPtr<JSWorkerContextPrototype> workerContextPrototype = new (m_globalData.get()) JSWorkerContextPrototype(workerContextPrototypeStructure.release());
+
+ if (m_workerContext->isDedicatedWorkerContext()) {
+ RefPtr<Structure> dedicatedContextPrototypeStructure = JSDedicatedWorkerContextPrototype::createStructure(workerContextPrototype);
+ ProtectedPtr<JSDedicatedWorkerContextPrototype> dedicatedContextPrototype = new (m_globalData.get()) JSDedicatedWorkerContextPrototype(dedicatedContextPrototypeStructure.release());
+ RefPtr<Structure> structure = JSDedicatedWorkerContext::createStructure(dedicatedContextPrototype);
+
+ m_workerContextWrapper = new (m_globalData.get()) JSDedicatedWorkerContext(structure.release(), m_workerContext->toDedicatedWorkerContext());
+#if ENABLE(SHARED_WORKERS)
+ } else {
+ ASSERT(m_workerContext->isSharedWorkerContext());
+ RefPtr<Structure> sharedContextPrototypeStructure = JSSharedWorkerContextPrototype::createStructure(workerContextPrototype);
+ ProtectedPtr<JSSharedWorkerContextPrototype> sharedContextPrototype = new (m_globalData.get()) JSSharedWorkerContextPrototype(sharedContextPrototypeStructure.release());
+ RefPtr<Structure> structure = JSSharedWorkerContext::createStructure(sharedContextPrototype);
+
+ m_workerContextWrapper = new (m_globalData.get()) JSSharedWorkerContext(structure.release(), m_workerContext->toSharedWorkerContext());
+#endif
+ }
}
ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
@@ -88,7 +103,7 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
ScriptValue exception;
ScriptValue result = evaluate(sourceCode, &exception);
if (exception.jsValue()) {
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
reportException(m_workerContextWrapper->globalExec(), exception.jsValue());
}
return result;
@@ -103,15 +118,13 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode,
}
initScriptIfNeeded();
- JSLock lock(false);
+ JSLock lock(SilenceAssertionsOnly);
ExecState* exec = m_workerContextWrapper->globalExec();
m_workerContextWrapper->globalData()->timeoutChecker.start();
Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper);
m_workerContextWrapper->globalData()->timeoutChecker.stop();
- m_workerContext->thread()->workerObjectProxy().reportPendingActivity(m_workerContext->hasPendingActivity());
-
if (comp.complType() == Normal || comp.complType() == ReturnValue)
return comp.value();