本文整理汇总了C++中WorkerContext::thread方法的典型用法代码示例。如果您正苦于以下问题:C++ WorkerContext::thread方法的具体用法?C++ WorkerContext::thread怎么用?C++ WorkerContext::thread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkerContext
的用法示例。
在下文中一共展示了WorkerContext::thread方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allowIndexedDB
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: performTask
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: canEstablishDatabase
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: performTask
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: waitForOperationToComplete
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: removeRequestFromCache
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: openFileSystem
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: create
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: runMessageLoopOnPause
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: create
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: performTask
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: deleteFileSystem
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: performTask
virtual void performTask(ScriptExecutionContext *context)
{
ASSERT(context->isWorkerContext());
WorkerContext* workerContext = static_cast<WorkerContext*>(context);
workerContext->thread()->runLoop().terminate();
}