// static WorkerContextProxy* WebWorkerClientImpl::createWorkerContextProxy(Worker* worker) { // Special behavior for multiple workers per process. // FIXME: v8 doesn't support more than one workers per process. // if (!worker->scriptExecutionContext()->isDocument()) // return new WorkerMessagingProxy(worker); WebWorker* webWorker = 0; WebWorkerClientImpl* proxy = new WebWorkerClientImpl(worker); if (worker->scriptExecutionContext()->isDocument()) { Document* document = static_cast<Document*>( worker->scriptExecutionContext()); WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); webWorker = webFrame->client()->createWorker(webFrame, proxy); } else { WorkerContextExecutionProxy* currentContext = WorkerContextExecutionProxy::retrieve(); if (!currentContext) { ASSERT_NOT_REACHED(); return 0; } DedicatedWorkerThread* thread = static_cast<DedicatedWorkerThread*>(currentContext->workerContext()->thread()); WorkerObjectProxy* workerObjectProxy = &thread->workerObjectProxy(); WebWorkerImpl* impl = reinterpret_cast<WebWorkerImpl*>(workerObjectProxy); webWorker = impl->client()->createWorker(proxy); } proxy->setWebWorker(webWorker); return proxy; }
ScriptExecutionContext* getScriptExecutionContext(ScriptState* scriptState) { #if ENABLE(WORKERS) WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve(); if (proxy) return proxy->workerContext()->scriptExecutionContext(); #endif if (scriptState) return scriptState->frame()->document()->scriptExecutionContext(); else { Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); if (frame) return frame->document()->scriptExecutionContext(); } return 0; }
ScriptExecutionContext* getScriptExecutionContext(ScriptState* scriptState) { #if ENABLE(WORKERS) WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve(); if (proxy) return proxy->workerContext()->scriptExecutionContext(); #endif Frame* frame; if (scriptState) { v8::HandleScope handleScope; frame = V8Proxy::retrieveFrame(scriptState->context()); } else frame = V8Proxy::retrieveFrameForCurrentContext(); if (frame) return frame->document()->scriptExecutionContext(); return 0; }