示例#1
0
PassRefPtrWillBeRawPtr<Worker> Worker::create(ExecutionContext* context, const String& url, ExceptionState& exceptionState)
{
    ASSERT(isMainThread());
    Document* document = toDocument(context);
    UseCounter::count(context, UseCounter::WorkerStart);
    if (!document->page()) {
        exceptionState.throwDOMException(InvalidAccessError, "The context provided is invalid.");
        return nullptr;
    }
    WorkerGlobalScopeProxyProvider* proxyProvider = WorkerGlobalScopeProxyProvider::from(*document->page());
    ASSERT(proxyProvider);

    RefPtrWillBeRawPtr<Worker> worker = adoptRefWillBeRefCountedGarbageCollected(new Worker(context));

    worker->suspendIfNeeded();

    KURL scriptURL = worker->resolveURL(url, exceptionState);
    if (scriptURL.isEmpty())
        return nullptr;

    // The worker context does not exist while loading, so we must ensure that the worker object is not collected, nor are its event listeners.
    worker->setPendingActivity(worker.get());

    worker->m_scriptLoader = WorkerScriptLoader::create();
    worker->m_scriptLoader->loadAsynchronously(*context, scriptURL, DenyCrossOriginRequests, worker.get());
    worker->m_contextProxy = proxyProvider->createWorkerGlobalScopeProxy(worker.get());
    return worker.release();
}
示例#2
0
PassRefPtrWillBeRawPtr<SharedWorker> SharedWorker::create(ExecutionContext* context, const String& url, const String& name, ExceptionState& exceptionState)
{
    ASSERT(isMainThread());
    ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument());

    UseCounter::count(context, UseCounter::SharedWorkerStart);

    RefPtrWillBeRawPtr<SharedWorker> worker = adoptRefWillBeRefCountedGarbageCollected(new SharedWorker(context));

    RefPtrWillBeRawPtr<MessageChannel> channel = MessageChannel::create(context);
    worker->m_port = channel->port1();
    OwnPtr<blink::WebMessagePortChannel> remotePort = channel->port2()->disentangle();
    ASSERT(remotePort);

    worker->suspendIfNeeded();

    // We don't currently support nested workers, so workers can only be created from documents.
    Document* document = toDocument(context);
    if (!document->securityOrigin()->canAccessSharedWorkers()) {
        exceptionState.throwSecurityError("Access to shared workers is denied to origin '" + document->securityOrigin()->toString() + "'.");
        return nullptr;
    }

    KURL scriptURL = worker->resolveURL(url, exceptionState);
    if (scriptURL.isEmpty())
        return nullptr;

    if (document->frame()->loader().client()->sharedWorkerRepositoryClient())
        document->frame()->loader().client()->sharedWorkerRepositoryClient()->connect(worker.get(), remotePort.release(), scriptURL, name, exceptionState);

    return worker.release();
}
 static PassRefPtrWillBeRawPtr<DataListIndicatorElement> create(Document& document)
 {
     RefPtrWillBeRawPtr<DataListIndicatorElement> element = adoptRefWillBeRefCountedGarbageCollected(new DataListIndicatorElement(document));
     element->setShadowPseudoId(AtomicString("-webkit-calendar-picker-indicator", AtomicString::ConstructFromLiteral));
     element->setAttribute(idAttr, ShadowElementNames::pickerIndicator());
     return element.release();
 }
示例#4
0
PassRefPtrWillBeRawPtr<MIDIAccess> MIDIAccess::create(ExecutionContext* context, MIDIAccessPromise* promise)
{
    RefPtrWillBeRawPtr<MIDIAccess> midiAccess(adoptRefWillBeRefCountedGarbageCollected(new MIDIAccess(context, promise)));
    midiAccess->suspendIfNeeded();
    midiAccess->startRequest();
    return midiAccess.release();
}
示例#5
0
PassRefPtrWillBeRawPtr<RTCDTMFSender> RTCDTMFSender::create(ExecutionContext* context, blink::WebRTCPeerConnectionHandler* peerConnectionHandler, PassRefPtrWillBeRawPtr<MediaStreamTrack> prpTrack, ExceptionState& exceptionState)
{
    RefPtrWillBeRawPtr<MediaStreamTrack> track = prpTrack;
    OwnPtr<blink::WebRTCDTMFSenderHandler> handler = adoptPtr(peerConnectionHandler->createDTMFSender(track->component()));
    if (!handler) {
        exceptionState.throwDOMException(NotSupportedError, "The MediaStreamTrack provided is not an element of a MediaStream that's currently in the local streams set.");
        return nullptr;
    }

    RefPtrWillBeRawPtr<RTCDTMFSender> dtmfSender = adoptRefWillBeRefCountedGarbageCollected(new RTCDTMFSender(context, track, handler.release()));
    dtmfSender->suspendIfNeeded();
    return dtmfSender.release();
}
示例#6
0
PassRefPtrWillBeRawPtr<WebSocket> WebSocket::create(ExecutionContext* context, const String& url, const Vector<String>& protocols, ExceptionState& exceptionState)
{
    if (url.isNull()) {
        exceptionState.throwDOMException(SyntaxError, "Failed to create a WebSocket: the provided URL is invalid.");
        return nullptr;
    }

    RefPtrWillBeRawPtr<WebSocket> webSocket(adoptRefWillBeRefCountedGarbageCollected(new WebSocket(context)));
    webSocket->suspendIfNeeded();

    webSocket->connect(url, protocols, exceptionState);
    if (exceptionState.hadException())
        return nullptr;

    return webSocket.release();
}
示例#7
0
// static
PassRefPtrWillBeRawPtr<SharedWorkerGlobalScope> SharedWorkerGlobalScope::create(const String& name, SharedWorkerThread* thread, PassOwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData)
{
    RefPtrWillBeRawPtr<SharedWorkerGlobalScope> context = adoptRefWillBeRefCountedGarbageCollected(new SharedWorkerGlobalScope(name, startupData->m_scriptURL, startupData->m_userAgent, thread, startupData->m_workerClients.release()));
    context->applyContentSecurityPolicyFromString(startupData->m_contentSecurityPolicy, startupData->m_contentSecurityPolicyType);
    return context.release();
}
示例#8
0
PassRefPtrWillBeRawPtr<CSSImageSetValue> CSSImageSetValue::cloneForCSSOM() const
{
    return adoptRefWillBeRefCountedGarbageCollected(new CSSImageSetValue(*this));
}
示例#9
0
PassRefPtrWillBeRawPtr<HTMLDataListElement> HTMLDataListElement::create(Document& document)
{
    UseCounter::count(document, UseCounter::DataListElement);
    return adoptRefWillBeRefCountedGarbageCollected(new HTMLDataListElement(document));
}
PassRefPtrWillBeRawPtr<NetworkInformation> NetworkInformation::create(ExecutionContext* context)
{
    RefPtrWillBeRawPtr<NetworkInformation> connection(adoptRefWillBeRefCountedGarbageCollected(new NetworkInformation(context)));
    connection->suspendIfNeeded();
    return connection.release();
}
示例#11
0
PassRefPtrWillBeRawPtr<HTMLShadowElement> HTMLShadowElement::create(Document& document)
{
    return adoptRefWillBeRefCountedGarbageCollected(new HTMLShadowElement(document));
}
示例#12
0
PassRefPtrWillBeRawPtr<MessagePort> MessagePort::create(ExecutionContext& executionContext)
{
    RefPtrWillBeRawPtr<MessagePort> port = adoptRefWillBeRefCountedGarbageCollected(new MessagePort(executionContext));
    port->suspendIfNeeded();
    return port.release();
}
示例#13
0
PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeySession::create(ExecutionContext* context, blink::WebContentDecryptionModule* cdm, WeakPtrWillBeRawPtr<MediaKeys> keys)
{
    RefPtrWillBeRawPtr<MediaKeySession> session(adoptRefWillBeRefCountedGarbageCollected(new MediaKeySession(context, cdm, keys)));
    session->suspendIfNeeded();
    return session.release();
}
示例#14
0
PassRefPtrWillBeRawPtr<HTMLDetailsElement> HTMLDetailsElement::create(Document& document)
{
    RefPtrWillBeRawPtr<HTMLDetailsElement> details = adoptRefWillBeRefCountedGarbageCollected(new HTMLDetailsElement(document));
    details->ensureUserAgentShadowRoot();
    return details.release();
}
示例#15
0
PassRefPtrWillBeRawPtr<MediaStreamTrackEvent> MediaStreamTrackEvent::create()
{
    return adoptRefWillBeRefCountedGarbageCollected(new MediaStreamTrackEvent);
}
PassRefPtrWillBeRawPtr<MediaController> MediaController::create(ExecutionContext* context)
{
    return adoptRefWillBeRefCountedGarbageCollected(new MediaController(context));
}
示例#17
0
PassRefPtrWillBeRawPtr<BatteryManager> BatteryManager::create(ExecutionContext* context)
{
    RefPtrWillBeRawPtr<BatteryManager> batteryManager(adoptRefWillBeRefCountedGarbageCollected(new BatteryManager(context)));
    batteryManager->suspendIfNeeded();
    return batteryManager.release();
}
示例#18
0
PassRefPtrWillBeRawPtr<MediaStreamTrackEvent> MediaStreamTrackEvent::create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<MediaStreamTrack> track)
{
    return adoptRefWillBeRefCountedGarbageCollected(new MediaStreamTrackEvent(type, canBubble, cancelable, track));
}
示例#19
0
PassRefPtrWillBeRawPtr<FileReader> FileReader::create(ExecutionContext* context)
{
    RefPtrWillBeRawPtr<FileReader> fileReader(adoptRefWillBeRefCountedGarbageCollected(new FileReader(context)));
    fileReader->suspendIfNeeded();
    return fileReader.release();
}
示例#20
0
// static
PassRefPtrWillBeRawPtr<DOMFileSystem> DOMFileSystem::create(ExecutionContext* context, const String& name, FileSystemType type, const KURL& rootURL)
{
    RefPtrWillBeRawPtr<DOMFileSystem> fileSystem(adoptRefWillBeRefCountedGarbageCollected(new DOMFileSystem(context, name, type, rootURL)));
    fileSystem->suspendIfNeeded();
    return fileSystem.release();
}