コード例 #1
0
bool IDBFactoryBackendProxy::allowIndexedDB(ScriptExecutionContext* context, const String& name, const WebSecurityOrigin& origin, PassRefPtr<IDBCallbacks> callbacks)
{
    bool allowed;
    ASSERT(context->isDocument() || context->isWorkerContext());
    if (context->isDocument()) {
        Document* document = static_cast<Document*>(context);
        WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
        WebViewImpl* webView = webFrame->viewImpl();
        // FIXME: webView->permissionClient() returns 0 in test_shell and content_shell http://crbug.com/137269
        allowed = !webView->permissionClient() || webView->permissionClient()->allowIndexedDB(webFrame, name, origin);
    } else {
        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
        WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(&workerContext->thread()->workerLoaderProxy());
        WorkerRunLoop& runLoop = workerContext->thread()->runLoop();

        String mode = allowIndexedDBMode;
        mode.append(String::number(runLoop.createUniqueId()));
        RefPtr<AllowIndexedDBMainThreadBridge> bridge = AllowIndexedDBMainThreadBridge::create(webWorkerBase, mode, name);

        // Either the bridge returns, or the queue gets terminated.
        if (runLoop.runInMode(workerContext, mode) == MessageQueueTerminated) {
            bridge->cancel();
            allowed = false;
        } else
            allowed = bridge->result();
    }

    if (!allowed)
        callbacks->onError(WebIDBDatabaseError(IDBDatabaseException::UNKNOWN_ERR, "The user denied permission to access the database."));

    return allowed;
}
コード例 #2
0
 virtual void performTask(ScriptExecutionContext *context)
 {
     ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerContext());
     WorkerContext* workerContext = static_cast<WorkerContext*>(context);
     // Notify parent that this context is closed. Parent is responsible for calling WorkerThread::stop().
     workerContext->thread()->workerReportingProxy().workerContextClosed();
 }
コード例 #3
0
bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecutionContext, const String& name, const String& displayName, unsigned long estimatedSize)
{
    ASSERT(scriptExecutionContext->isContextThread());
    ASSERT(scriptExecutionContext->isDocument() || scriptExecutionContext->isWorkerContext());
    if (scriptExecutionContext->isDocument()) {
        Document* document = static_cast<Document*>(scriptExecutionContext);
        WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
        if (!webFrame)
            return false;
        WebViewImpl* webView = webFrame->viewImpl();
        if (!webView)
            return false;
        if (webView->permissionClient())
            return webView->permissionClient()->allowDatabase(webFrame, name, displayName, estimatedSize);
    } else {
#if ENABLE(WORKERS)
        WorkerContext* workerContext = static_cast<WorkerContext*>(scriptExecutionContext);
        WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
        NewWebWorkerBase* webWorker = static_cast<NewWebWorkerBase*>(workerLoaderProxy);
        return allowDatabaseForWorker(webWorker->newCommonClient(), webWorker->view()->mainFrame(), name, displayName, estimatedSize);
#else
        ASSERT_NOT_REACHED();
#endif
    }

    return true;
}
コード例 #4
0
 virtual void performTask(ScriptExecutionContext *context)
 {
     ASSERT(context->isWorkerContext());
     WorkerContext* workerContext = static_cast<WorkerContext*>(context);
     // It's not safe to call clearScript until all the cleanup tasks posted by functions initiated by WorkerThreadShutdownStartTask have completed.
     workerContext->clearScript();
     workerContext->thread()->runLoop().terminate();
 }
コード例 #5
0
bool WorkerFileWriterCallbacksBridge::waitForOperationToComplete()
{
    while (m_operationInProgress) {
        WorkerContext* context = static_cast<WorkerContext*>(m_workerContext);
        if (context->thread()->runLoop().runInMode(context, m_mode) == MessageQueueTerminated)
            return false;
    }
    return true;
}
コード例 #6
0
ファイル: MemoryCache.cpp プロジェクト: jbat100/webkit
void MemoryCache::removeRequestFromCache(ScriptExecutionContext* context, const ResourceRequest& request)
{
#if ENABLE(WORKERS)
    if (context->isWorkerContext()) {
        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
        workerContext->thread()->workerLoaderProxy().postTaskToLoader(createCallbackTask(&crossThreadRemoveRequestFromCache, request));
        return;
    }
#endif

    removeRequestFromCacheImpl(context, request);
}
コード例 #7
0
static void openFileSystem(ScriptExecutionContext* context, const String& basePath, FileSystemType type, long long size, bool create, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileSystemSynchronousType synchronousType)
{
    ASSERT(context);
    ASSERT(type != FileSystemTypeIsolated);
    if (type == FileSystemTypeIsolated)
        return;

    KURL url = context->url();
    if (url.hasFragmentIdentifier())
        url.removeFragmentIdentifier();
    url.setQuery(String());
    url.setPath("/");
    StringBuilder builder;
    builder.append("filesystem:");
    builder.append(url.string());
    builder.append(fileSystemTypeString(type));
    KURL rootURL = context->completeURL(builder.toString());
    ASSERT(rootURL.isValid());

    // TODO: Ask user for file system permission.

    if (context->isDocument()) {
        int playerId = 0;
        Page* page = static_cast<Document*>(context)->page();
        if (page)
            playerId = page->chrome().client()->platformPageClient()->playerID();
        AsyncFileSystemBlackBerry::openFileSystem(rootURL, basePath, context->securityOrigin()->databaseIdentifier(), type, size, create, playerId, callbacks);
    } else {
#if ENABLE(WORKERS)
        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
        String mode = openFileSystemMode;
        mode.append(String::number(workerContext->thread()->runLoop().createUniqueId()));
        WorkerAsyncFileSystemBlackBerry::openFileSystem(workerContext, rootURL, mode, basePath, context->securityOrigin()->databaseIdentifier(), type, size, create, callbacks);
        if (synchronousType == SynchronousFileSystem)
            workerContext->thread()->runLoop().runInMode(workerContext, mode);
#else
        ASSERT_NOT_REACHED();
#endif
    }
}
コード例 #8
0
PassRefPtr<ThreadableWebSocketChannel> ThreadableWebSocketChannel::create(ScriptExecutionContext* context, WebSocketChannelClient* client)
{
    ASSERT(context);
    ASSERT(client);

#if ENABLE(WORKERS)
    if (context->isWorkerContext()) {
        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
        WorkerRunLoop& runLoop = workerContext->thread()->runLoop();
        String mode = webSocketChannelMode;
        mode.append(String::number(runLoop.createUniqueId()));
        return WorkerThreadableWebSocketChannel::create(workerContext, client, mode);
    }
#endif // ENABLE(WORKERS)

    return WebSocketChannel::create(toDocument(context), client);
}
コード例 #9
0
void WorkerScriptDebugServer::runMessageLoopOnPause(v8::Handle<v8::Context> context)
{
    WorkerContext* workerContext = retrieveWorkerContext(context);
    WorkerThread* workerThread = workerContext->thread();

    m_pausedWorkerContext = workerContext;

    MessageQueueWaitResult result;
    do {
        result = workerThread->runLoop().runInMode(workerContext, debuggerTaskMode);
    // Keep waiting until execution is resumed.
    } while (result == MessageQueueMessageReceived && isPaused());
    m_pausedWorkerContext = 0;
    
    // The listener may have been removed in the nested loop.
    if (ScriptDebugListener* listener = m_listenersMap.get(workerContext))
        listener->didContinue();
}
コード例 #10
0
PassRefPtr<WebSocketChannel> WebSocketChannel::create(ScriptExecutionContext* context, WebSocketChannelClient* client)
{
    ASSERT(context);
    ASSERT(client);

    if (context->isWorkerContext()) {
        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
        WorkerRunLoop& runLoop = workerContext->thread()->runLoop();
        String mode = webSocketChannelMode;
        mode.append(String::number(runLoop.createUniqueId()));
        return WorkerThreadableWebSocketChannel::create(workerContext, client, mode);
    }

    if (RuntimeEnabledFeatures::experimentalWebSocketEnabled()) {
        // FIXME: Create and return an "experimental" WebSocketChannel instead of a MainThreadWebSocketChannel.
        return MainThreadWebSocketChannel::create(toDocument(context), client);
    }
    return MainThreadWebSocketChannel::create(toDocument(context), client);
}
コード例 #11
0
    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());
    }
コード例 #12
0
void LocalFileSystem::deleteFileSystem(ScriptExecutionContext* context, FileSystemType type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
{
    ASSERT(context);
    ASSERT(type != FileSystemTypeIsolated);
    if (type == FileSystemTypeIsolated)
        return;

    // TODO: Ask user for file system permission.

    if (context->isDocument())
        AsyncFileSystemBlackBerry::deleteFileSystem(fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, callbacks);
    else {
#if ENABLE(WORKERS)
        WorkerContext* workerContext = static_cast<WorkerContext*>(context);
        String mode = deleteFileSystemMode;
        mode.append(String::number(workerContext->thread()->runLoop().createUniqueId()));
        WorkerAsyncFileSystemBlackBerry::deleteFileSystem(workerContext, mode, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, callbacks);
#else
        ASSERT_NOT_REACHED();
#endif
    }
}
コード例 #13
0
 virtual void performTask(ScriptExecutionContext *context)
 {
     ASSERT(context->isWorkerContext());
     WorkerContext* workerContext = static_cast<WorkerContext*>(context);
     workerContext->thread()->runLoop().terminate();
 }