コード例 #1
0
ファイル: FileReader.cpp プロジェクト: houzhenggang/webkit
void FileReader::abort()
{
    LOG(FileAPI, "FileReader: aborting\n");

    if (m_aborting || m_state != LOADING)
        return;
    m_aborting = true;

    // Schedule to have the abort done later since abort() might be called from the event handler and we do not want the resource loading code to be in the stack.
    scriptExecutionContext()->postTask([this] (ScriptExecutionContext&) {
        ASSERT(m_state != DONE);

        terminate();
        m_aborting = false;

        m_error = FileError::create(FileError::ABORT_ERR);

        fireEvent(eventNames().errorEvent);
        fireEvent(eventNames().abortEvent);
        fireEvent(eventNames().loadendEvent);

        // All possible events have fired and we're done, no more pending activity.
        unsetPendingActivity(this);
    });
}
コード例 #2
0
ファイル: Notification.cpp プロジェクト: 3163504123/phantomjs
void Notification::finalize()
{
    if (m_state == Closed)
        return;
    m_state = Closed;
    unsetPendingActivity(this);
}
コード例 #3
0
ファイル: FileWriter.cpp プロジェクト: yang-bo/webkit
void FileWriter::didWrite(long long bytes, bool complete)
{
    if (m_operationInProgress == OperationAbort) {
        completeAbort();
        return;
    }
    ASSERT(m_readyState == WRITING);
    ASSERT(m_truncateLength == -1);
    ASSERT(m_operationInProgress == OperationWrite);
    ASSERT(bytes + m_bytesWritten > 0);
    ASSERT(bytes + m_bytesWritten <= m_bytesToWrite);
    m_bytesWritten += bytes;
    ASSERT((m_bytesWritten == m_bytesToWrite) || !complete);
    setPosition(position() + bytes);
    if (position() > length())
        setLength(position());
    if (complete) {
        m_blobBeingWritten.clear();
        m_operationInProgress = OperationNone;
    }
    // TODO: Throttle to no more frequently than every 50ms.
    int numAborts = m_numAborts;
    fireEvent(eventNames().progressEvent);
    // We could get an abort in the handler for this event. If we do, it's
    // already handled the cleanup and signalCompletion call.
    if (complete) {
      if (numAborts == m_numAborts)
          signalCompletion(FileError::OK);
      unsetPendingActivity(this);
    }
}
コード例 #4
0
void Notification::finishLoading()
{
    if (m_state == Loading) {
        if (m_notificationCenter->presenter() && m_notificationCenter->presenter()->show(this))
            m_state = Showing;
    }
    unsetPendingActivity(this);
}
コード例 #5
0
void FileWriter::completeAbort()
{
    ASSERT(m_operationInProgress == OperationAbort);
    m_operationInProgress = OperationNone;
    Operation operation = m_queuedOperation;
    m_queuedOperation = OperationNone;
    doOperation(operation);
    unsetPendingActivity(this);
}
void SharedWorkerScriptLoader::notifyFinished()
{
    // Hand off the just-loaded code to the repository to start up the worker thread.
    if (m_scriptLoader->failed())
        m_worker->dispatchLoadErrorEvent();
    else
        DefaultSharedWorkerRepository::instance().workerScriptLoaded(*m_proxy, scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), m_port.release());

    // This frees this object - must be the last action in this function.
    unsetPendingActivity(this);
}
コード例 #7
0
void Worker::notifyFinished()
{
    if (m_scriptLoader->failed())
        dispatchEvent(Event::create(eventNames().errorEvent, false, true));
    else
        m_contextProxy->startWorkerContext(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script());

    m_scriptLoader = 0;

    unsetPendingActivity(this);
}
コード例 #8
0
void EventSource::networkRequestEnded()
{
    ASSERT(m_requestInFlight);

    m_requestInFlight = false;

    if (m_state != CLOSED)
        scheduleReconnect();
    else
        unsetPendingActivity(this);
}
コード例 #9
0
ファイル: Worker.cpp プロジェクト: caiolima/webkit
void Worker::notifyFinished()
{
    if (m_scriptLoader->failed())
        dispatchEvent(Event::create(eventNames().errorEvent, false, true));
    else {
        const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders = m_contentSecurityPolicyResponseHeaders ? m_contentSecurityPolicyResponseHeaders.value() : scriptExecutionContext()->contentSecurityPolicy()->responseHeaders();
        m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, DontPauseWorkerGlobalScopeOnStart);
        InspectorInstrumentation::scriptImported(scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script());
    }
    m_scriptLoader = nullptr;

    unsetPendingActivity(this);
}
コード例 #10
0
ファイル: Worker.cpp プロジェクト: josedealcala/webkit
void Worker::notifyFinished()
{
    if (m_scriptLoader->failed())
        dispatchEvent(Event::create(eventNames().errorEvent, false, true));
    else {
        WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart;
        m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), startMode);
        InspectorInstrumentation::scriptImported(scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script());
    }
    m_scriptLoader = nullptr;

    unsetPendingActivity(this);
}
コード例 #11
0
ファイル: XMLHttpRequest.cpp プロジェクト: MYSHLIFE/webkit
void XMLHttpRequest::dropProtection()
{
    // The XHR object itself holds on to the responseText, and
    // thus has extra cost even independent of any
    // responseText or responseXML objects it has handed
    // out. But it is protected from GC while loading, so this
    // can't be recouped until the load is done, so only
    // report the extra cost at that point.
    JSC::VM* vm = scriptExecutionContext()->vm();
    JSC::JSLockHolder lock(vm);
    vm->heap.reportExtraMemoryCost(m_responseBuilder.length() * 2);

    unsetPendingActivity(this);
}
コード例 #12
0
ファイル: EventSource.cpp プロジェクト: kodybrown/webkit
void EventSource::abortConnectionAttempt()
{
    ASSERT(m_state == CONNECTING);

    if (m_requestInFlight)
        m_loader->cancel();
    else {
        m_state = CLOSED;
        unsetPendingActivity(this);
    }

    ASSERT(m_state == CLOSED);
    dispatchEvent(Event::create(eventNames().errorEvent, false, false));
}
コード例 #13
0
ファイル: EventSource.cpp プロジェクト: Mr-Kumar-Abhishek/qt
void EventSource::endRequest()
{
    m_requestInFlight = false;

    if (!m_failSilently)
        dispatchEvent(Event::create(eventNames().errorEvent, false, false));

    if (!scriptExecutionContext()->isWorkerContext())
        cache()->loader()->nonCacheRequestComplete(m_url);

    if (m_state != CLOSED)
        scheduleReconnect();
    else
        unsetPendingActivity(this);
}
コード例 #14
0
void FileWriter::didFail(blink::WebFileError code)
{
    ASSERT(m_operationInProgress != OperationNone);
    ASSERT(static_cast<FileError::ErrorCode>(code) != FileError::OK);
    if (m_operationInProgress == OperationAbort) {
        completeAbort();
        return;
    }
    ASSERT(m_queuedOperation == OperationNone);
    ASSERT(m_readyState == WRITING);
    m_blobBeingWritten.clear();
    m_operationInProgress = OperationNone;
    signalCompletion(static_cast<FileError::ErrorCode>(code));
    unsetPendingActivity(this);
}
コード例 #15
0
ファイル: Worker.cpp プロジェクト: Tkkg1994/Platfrom-kccat6
void Worker::notifyFinished()
{
    if (m_scriptLoader->failed()) {
        dispatchEvent(Event::createCancelable(EventTypeNames::error));
    } else {
        WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart;
        if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(executionContext()))
            startMode = PauseWorkerGlobalScopeOnStart;
        m_contextProxy->startWorkerGlobalScope(m_scriptLoader->url(), executionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), startMode);
        InspectorInstrumentation::scriptImported(executionContext(), m_scriptLoader->identifier(), m_scriptLoader->script());
    }
    m_scriptLoader = nullptr;

    unsetPendingActivity(this);
}
コード例 #16
0
void Worker::notifyFinished()
{
    if (m_scriptLoader->failed())
        dispatchEvent(Event::create(eventNames().errorEvent, false, true));
    else {
        m_contextProxy->startWorkerContext(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script());
#if ENABLE(INSPECTOR)
        if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
            inspector->scriptImported(m_scriptLoader->identifier(), m_scriptLoader->script());
#endif
    }
    m_scriptLoader = 0;

    unsetPendingActivity(this);
}
コード例 #17
0
void FileWriter::didTruncate()
{
    if (m_operationInProgress == OperationAbort) {
        completeAbort();
        return;
    }
    ASSERT(m_operationInProgress == OperationTruncate);
    ASSERT(m_truncateLength >= 0);
    setLength(m_truncateLength);
    if (position() > length())
        setPosition(length());
    m_operationInProgress = OperationNone;
    signalCompletion(FileError::OK);
    unsetPendingActivity(this);
}
コード例 #18
0
void FileReader::didFinishLoading()
{
    if (m_aborting)
        return;

    ASSERT(m_state != DONE);
    m_state = DONE;

    fireEvent(eventNames().progressEvent);
    fireEvent(eventNames().loadEvent);
    fireEvent(eventNames().loadendEvent);
    
    // All possible events have fired and we're done, no more pending activity.
    unsetPendingActivity(this);
}
コード例 #19
0
ファイル: XMLHttpRequest.cpp プロジェクト: jparound30/webkit
void XMLHttpRequest::dropProtection()
{
#if USE(JSC)
    // The XHR object itself holds on to the responseText, and
    // thus has extra cost even independent of any
    // responseText or responseXML objects it has handed
    // out. But it is protected from GC while loading, so this
    // can't be recouped until the load is done, so only
    // report the extra cost at that point.
    JSC::JSLock lock(JSC::SilenceAssertionsOnly);
    JSC::JSGlobalData* globalData = scriptExecutionContext()->globalData();
    globalData->heap.reportExtraMemoryCost(m_responseBuilder.length() * 2);
#endif

    unsetPendingActivity(this);
}
コード例 #20
0
void AudioContext::clear()
{
    // We have to release our reference to the destination node before the context will ever be deleted since the destination node holds a reference to the context.
    if (m_destinationNode)
        m_destinationNode.clear();

    // Audio thread is dead. Nobody will schedule node deletion action. Let's do it ourselves.
    do {
        deleteMarkedNodes();
        m_nodesToDelete.appendVector(m_nodesMarkedForDeletion);
        m_nodesMarkedForDeletion.clear();
    } while (m_nodesToDelete.size());

    // It was set in constructCommon.
    unsetPendingActivity(this);
}
コード例 #21
0
ファイル: XMLHttpRequest.cpp プロジェクト: st3fan/webkit
void XMLHttpRequest::dropProtection()
{
    // The XHR object itself holds on to the responseText, and
    // thus has extra cost even independent of any
    // responseText or responseXML objects it has handed
    // out. But it is protected from GC while loading, so this
    // can't be recouped until the load is done, so only
    // report the extra cost at that point.
    JSC::VM& vm = scriptExecutionContext()->vm();
    JSC::JSLockHolder lock(vm);
    // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
    // https://bugs.webkit.org/show_bug.cgi?id=142595
    vm.heap.deprecatedReportExtraMemory(m_responseBuilder.length() * 2);

    unsetPendingActivity(this);
}
コード例 #22
0
void XMLHttpRequest::dropProtection()
{
#if USE(JSC)
    // The XHR object itself holds on to the responseText, and
    // thus has extra cost even independent of any
    // responseText or responseXML objects it has handed
    // out. But it is protected from GC while loading, so this
    // can't be recouped until the load is done, so only
    // report the extra cost at that point.
    JSC::JSGlobalData* globalData = scriptExecutionContext()->globalData();
    if (hasCachedDOMObjectWrapper(globalData, this))
        globalData->heap.reportExtraMemoryCost(m_responseText.size() * 2);
#endif

    unsetPendingActivity(this);
}
コード例 #23
0
ファイル: EventSource.cpp プロジェクト: Mr-Kumar-Abhishek/qt
void EventSource::close()
{
    if (m_state == CLOSED)
        return;

    if (m_reconnectTimer.isActive()) {
        m_reconnectTimer.stop();
        unsetPendingActivity(this);
    }

    m_state = CLOSED;
    m_failSilently = true;

    if (m_requestInFlight)
        m_loader->cancel();
}
コード例 #24
0
void FileReader::didFail(int errorCode)
{
    // If we're aborting, do not proceed with normal error handling since it is covered in aborting code.
    if (m_aborting)
        return;

    ASSERT(m_state != DONE);
    m_state = DONE;

    m_error = FileError::create(static_cast<FileError::ErrorCode>(errorCode));
    fireEvent(eventNames().errorEvent);
    fireEvent(eventNames().loadendEvent);
    
    // All possible events have fired and we're done, no more pending activity.
    unsetPendingActivity(this);
}
コード例 #25
0
void FileReader::doAbort()
{
    ASSERT(m_state != DONE);

    terminate();
    m_aborting = false;

    m_error = FileError::create(FileError::ABORT_ERR);

    fireEvent(eventNames().errorEvent);
    fireEvent(eventNames().abortEvent);
    fireEvent(eventNames().loadendEvent);

    // All possible events have fired and we're done, no more pending activity.
    unsetPendingActivity(this);
}
コード例 #26
0
ファイル: Worker.cpp プロジェクト: jackiekaon/owb-mirror
void Worker::notifyFinished(CachedResource* resource)
{
    ASSERT(resource == m_cachedScript.get());
    if (m_cachedScript->errorOccurred())
        dispatchErrorEvent();
    else {
        String userAgent = document()->frame() ? document()->frame()->loader()->userAgent(m_scriptURL) : String();
        RefPtr<WorkerThread> thread = WorkerThread::create(m_scriptURL, userAgent, m_cachedScript->script(), m_messagingProxy);
        m_messagingProxy->workerThreadCreated(thread);
        thread->start();
    }

    m_cachedScript->removeClient(this);
    m_cachedScript = 0;

    unsetPendingActivity(this);
}
コード例 #27
0
void XMLHttpRequest::dropProtection()        
{
#if USE(JSC)
    // The XHR object itself holds on to the responseText, and
    // thus has extra cost even independent of any
    // responseText or responseXML objects it has handed
    // out. But it is protected from GC while loading, so this
    // can't be recouped until the load is done, so only
    // report the extra cost at that point.

   if (JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext()))
       if (DOMObject* wrapper = getCachedDOMObjectWrapper(*globalObject->globalData(), this))
           JSC::Heap::heap(wrapper)->reportExtraMemoryCost(m_responseText.size() * 2);
#endif

    unsetPendingActivity(this);
}
コード例 #28
0
ファイル: EventSource.cpp プロジェクト: kodybrown/webkit
void EventSource::close()
{
    if (m_state == CLOSED) {
        ASSERT(!m_requestInFlight);
        return;
    }

    // Stop trying to connect/reconnect if EventSource was explicitly closed or if ActiveDOMObject::stop() was called.
    if (m_connectTimer.isActive())
        m_connectTimer.stop();

    if (m_requestInFlight)
        m_loader->cancel();
    else {
        m_state = CLOSED;
        unsetPendingActivity(this);
    }
}
コード例 #29
0
void Worker::notifyFinished()
{
    if (m_scriptLoader->failed()) {
#if PLATFORM(BLACKBERRY)
        Olympia::Platform::didCancelStartingWorker();
#endif
        dispatchEvent(Event::create(eventNames().errorEvent, false, true));
    } else {
#if ENABLE(GROUP_BASED_DATABASE)
        m_contextProxy->startWorkerContext(m_scriptLoader->url(), scriptExecutionContext()->groupName(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script());
#else
        m_contextProxy->startWorkerContext(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script());
#endif

#if ENABLE(INSPECTOR)
        if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
            inspector->scriptImported(m_scriptLoader->identifier(), m_scriptLoader->script());
#endif
    }
    m_scriptLoader = 0;

    unsetPendingActivity(this);
}
コード例 #30
0
void FileWriter::didWrite(long long bytes, bool complete)
{
    if (m_operationInProgress == OperationAbort) {
        completeAbort();
        return;
    }
    ASSERT(m_readyState == WRITING);
    ASSERT(m_truncateLength == -1);
    ASSERT(m_operationInProgress == OperationWrite);
    ASSERT(!m_bytesToWrite || bytes + m_bytesWritten > 0);
    ASSERT(bytes + m_bytesWritten <= m_bytesToWrite);
    m_bytesWritten += bytes;
    ASSERT((m_bytesWritten == m_bytesToWrite) || !complete);
    setPosition(position() + bytes);
    if (position() > length())
        setLength(position());
    if (complete) {
        m_blobBeingWritten.clear();
        m_operationInProgress = OperationNone;
    }

    int numAborts = m_numAborts;
    // We could get an abort in the handler for this event. If we do, it's
    // already handled the cleanup and signalCompletion call.
    double now = currentTimeMS();
    if (complete || !m_lastProgressNotificationTimeMS || (now - m_lastProgressNotificationTimeMS > progressNotificationIntervalMS)) {
        m_lastProgressNotificationTimeMS = now;
        fireEvent(eventNames().progressEvent);
    }

    if (complete) {
      if (numAborts == m_numAborts)
          signalCompletion(FileError::OK);
      unsetPendingActivity(this);
    }
}