コード例 #1
0
ファイル: ActiveDOMCallback.cpp プロジェクト: BGmot/Qt
static void destroyOnContextThread(PassOwnPtr<ActiveDOMObjectCallbackImpl> impl)
{
    OwnPtr<ActiveDOMObjectCallbackImpl> implOwnPtr = impl;

    ScriptExecutionContext* context = implOwnPtr->scriptExecutionContext();
    MutexLocker locker(implOwnPtr->mutex());
    if (context && !context->isContextThread())
        context->postTask(DestroyOnContextThreadTask::create(implOwnPtr.release()));
}
コード例 #2
0
void SQLTransactionClient::didCommitWriteTransaction(DatabaseBackendBase* database)
{
    ScriptExecutionContext* scriptExecutionContext = database->databaseContext()->scriptExecutionContext();
    if (!scriptExecutionContext->isContextThread()) {
        scriptExecutionContext->postTask(NotifyDatabaseChangedTask::create(database));
        return;
    }

    WebCore::DatabaseObserver::databaseModified(database);
}
コード例 #3
0
Database::~Database()
{
    // The reference to the ScriptExecutionContext needs to be cleared on the JavaScript thread.  If we're on that thread already, we can just let the RefPtr's destruction do the dereffing.
    if (!m_scriptExecutionContext->isContextThread()) {
        // Grab a pointer to the script execution here because we're releasing it when we pass it to
        // DerefContextTask::create.
        ScriptExecutionContext* scriptExecutionContext = m_scriptExecutionContext.get();
        
        scriptExecutionContext->postTask(DerefContextTask::create(m_scriptExecutionContext.release()));
    }
}
コード例 #4
0
void CryptoAlgorithmRSA_OAEP::platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& key, Vector<uint8_t>&& cipherText, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
{
    context.ref();
    workQueue.dispatch([parameters = WTFMove(parameters), key = WTFMove(key), cipherText = WTFMove(cipherText), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
        auto& rsaParameters = downcast<CryptoAlgorithmRsaOaepParams>(*parameters);
        auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
        auto result = decryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText.data(), cipherText.size());
        if (result.hasException()) {
            context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
                exceptionCallback(ec);
                context.deref();
            });
            return;
        }
        context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
            callback(result);
            context.deref();
        });
    });
}
コード例 #5
0
JSSQLTransactionSyncCallback::~JSSQLTransactionSyncCallback()
{
    ScriptExecutionContext* context = scriptExecutionContext();
    // When the context is destroyed, all tasks with a reference to a callback
    // should be deleted. So if the context is 0, we are on the context thread.
    if (!context || context->isContextThread())
        delete m_data;
    else
        context->postTask(DeleteCallbackDataTask::create(m_data));
#ifndef NDEBUG
    m_data = 0;
#endif
}
コード例 #6
0
JSTestCallbackFunction::~JSTestCallbackFunction()
{
    ScriptExecutionContext* context = scriptExecutionContext();
    // When the context is destroyed, all tasks with a reference to a callback
    // should be deleted. So if the context is 0, we are on the context thread.
    if (!context || context->isContextThread())
        delete m_data;
    else
        context->postTask(DeleteCallbackDataTask(m_data));
#ifndef NDEBUG
    m_data = nullptr;
#endif
}
コード例 #7
0
void CryptoAlgorithmSHA1::digest(Vector<uint8_t>&& message, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
{
    auto digest = CryptoDigest::create(CryptoDigest::Algorithm::SHA_1);
    if (!digest) {
        exceptionCallback(OperationError);
        return;
    }

    context.ref();
    workQueue.dispatch([digest = WTFMove(digest), message = WTFMove(message), callback = WTFMove(callback), &context]() mutable {
        digest->addBytes(message.data(), message.size());
        auto result = digest->computeHash();
        context.postTask([callback = WTFMove(callback), result = WTFMove(result)](ScriptExecutionContext& context) {
            callback(result);
            context.deref();
        });
    });
}