Example #1
0
void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, PassOwnPtr<MessagePortChannel> channel)
{
    // Wrap the passed-in channel in a MessagePort, and send it off via a connect event.
    RefPtr<MessagePort> port = MessagePort::create(*context);
    port->entangle(channel);
    ASSERT(context->isWorkerContext());
    WorkerContext* workerContext = static_cast<WorkerContext*>(context);
    ASSERT(workerContext->isSharedWorkerContext());
    workerContext->dispatchEvent(createConnectEvent(port));
}
 virtual void performTask(ScriptExecutionContext* scriptContext)
 {
     RefPtr<MessagePort> port = MessagePort::create(*scriptContext);
     port->entangle(m_channel.release());
     ASSERT(scriptContext->isWorkerContext());
     WorkerContext* workerContext = static_cast<WorkerContext*>(scriptContext);
     // Since close() stops the thread event loop, this should not ever get called while closing.
     ASSERT(!workerContext->isClosing());
     ASSERT(workerContext->isSharedWorkerContext());
     workerContext->dispatchEvent(createConnectEvent(port));
 }
Example #3
0
JSValue JSC_HOST_CALL jsWorkerContextPrototypeFunctionDispatchEvent(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.isObject(&JSWorkerContext::s_info))
        return throwError(exec, TypeError);
    JSWorkerContext* castedThisObj = static_cast<JSWorkerContext*>(asObject(thisValue));
    WorkerContext* imp = static_cast<WorkerContext*>(castedThisObj->impl());
    ExceptionCode ec = 0;
    Event* evt = toEvent(args.at(0));


    JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec));
    setDOMException(exec, ec);
    return result;
}
static v8::Handle<v8::Value> dispatchEventCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.WorkerContext.dispatchEvent");
    WorkerContext* imp = V8WorkerContext::toNative(args.Holder());
    ExceptionCode ec = 0;
    {
    EXCEPTION_BLOCK(Event*, evt, V8Event::HasInstance(args[0]) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
    bool result = imp->dispatchEvent(evt, ec);
    if (UNLIKELY(ec))
        goto fail;
    return v8Boolean(result);
    }
    fail:
    V8Proxy::setDOMException(ec);
    return v8::Handle<v8::Value>();
}
    virtual void performTask(ScriptExecutionContext* scriptContext)
    {
        ASSERT(scriptContext->isWorkerContext());
        WorkerContext* context = static_cast<WorkerContext*>(scriptContext);

        RefPtr<Event> evt = MessageEvent::create(m_message, "", "", 0, 0);

        if (context->onmessage()) {
            evt->setTarget(context);
            evt->setCurrentTarget(context);
            context->onmessage()->handleEvent(evt.get(), false);
        }

        ExceptionCode ec = 0;
        context->dispatchEvent(evt.release(), ec);
        ASSERT(!ec);

        context->thread()->messagingProxy()->confirmWorkerThreadMessage(context->hasPendingActivity());
    }