本文整理汇总了C++中WorkerGlobalScope类的典型用法代码示例。如果您正苦于以下问题:C++ WorkerGlobalScope类的具体用法?C++ WorkerGlobalScope怎么用?C++ WorkerGlobalScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WorkerGlobalScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performTask
virtual void performTask(ScriptExecutionContext *context)
{
ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope());
WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(context);
// It's not safe to call clearScript until all the cleanup tasks posted by functions initiated by WorkerThreadShutdownStartTask have completed.
workerGlobalScope->clearScript();
}
示例2: ASSERT
double WorkerPerformance::now(ExecutionContext* context) const
{
ASSERT(context);
ASSERT(context->isWorkerGlobalScope());
WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
return 1000.0 * (monotonicallyIncreasingTime() - workerGlobalScope->timeOrigin());
}
示例3: performTask
virtual void performTask(ScriptExecutionContext *context)
{
WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
#if ENABLE(SQL_DATABASE)
// FIXME: Should we stop the databases as part of stopActiveDOMObjects() below?
DatabaseTaskSynchronizer cleanupSync;
DatabaseManager::manager().stopDatabases(workerGlobalScope, &cleanupSync);
#endif
workerGlobalScope->stopActiveDOMObjects();
workerGlobalScope->notifyObserversOfStop();
// Event listeners would keep DOMWrapperWorld objects alive for too long. Also, they have references to JS objects,
// which become dangling once Heap is destroyed.
workerGlobalScope->removeAllEventListeners();
#if ENABLE(SQL_DATABASE)
// We wait for the database thread to clean up all its stuff so that we
// can do more stringent leak checks as we exit.
cleanupSync.waitForTaskCompletion();
#endif
// Stick a shutdown command at the end of the queue, so that we deal
// with all the cleanup tasks the databases post first.
workerGlobalScope->postTask(WorkerThreadShutdownFinishTask::create());
}
示例4: ASSERT
bool DatabaseObserver::canEstablishDatabase(ExecutionContext* executionContext, const String& name, const String& displayName, unsigned long estimatedSize)
{
ASSERT(executionContext->isContextThread());
ASSERT(executionContext->isDocument() || executionContext->isWorkerGlobalScope());
if (executionContext->isDocument()) {
Document* document = toDocument(executionContext);
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 {
WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(executionContext);
WorkerPermissionClient* permissionClient = WorkerPermissionClient::from(workerGlobalScope);
if (permissionClient->proxy())
return permissionClient->allowDatabase(name, displayName, estimatedSize);
// FIXME: Deprecate this bridge code when PermissionClientProxy is
// implemented by the embedder.
WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope->thread()->workerLoaderProxy().toWebWorkerBase());
WebView* view = webWorker->view();
if (!view)
return false;
return allowDatabaseForWorker(view->mainFrame(), name, displayName, estimatedSize);
}
return true;
}
示例5: from
static ThrottlingController* from(ExecutionContext* context)
{
if (!context)
return 0;
if (context->isDocument()) {
Document* document = toDocument(context);
if (!document->frame())
return 0;
ThrottlingController* controller = static_cast<ThrottlingController*>(WillBeHeapSupplement<LocalFrame>::from(document->frame(), supplementName()));
if (controller)
return controller;
controller = new ThrottlingController();
WillBeHeapSupplement<LocalFrame>::provideTo(*document->frame(), supplementName(), adoptPtrWillBeNoop(controller));
return controller;
}
ASSERT(!isMainThread());
ASSERT(context->isWorkerGlobalScope());
WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
ThrottlingController* controller = static_cast<ThrottlingController*>(WillBeHeapSupplement<WorkerClients>::from(workerGlobalScope->clients(), supplementName()));
if (controller)
return controller;
controller = new ThrottlingController();
WillBeHeapSupplement<WorkerClients>::provideTo(*workerGlobalScope->clients(), supplementName(), adoptPtrWillBeNoop(controller));
return controller;
}
示例6: ASSERT
bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecutionContext, const String& name, const String& displayName, unsigned long estimatedSize)
{
ASSERT(scriptExecutionContext->isContextThread());
ASSERT(scriptExecutionContext->isDocument() || scriptExecutionContext->isWorkerGlobalScope());
if (scriptExecutionContext->isDocument()) {
Document* document = toDocument(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 {
WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(scriptExecutionContext);
WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerGlobalScope->thread()->workerLoaderProxy().toWebWorkerBase());
WebView* view = webWorker->view();
if (!view)
return false;
return allowDatabaseForWorker(view->mainFrame(), name, displayName, estimatedSize);
}
return true;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:25,代码来源:DatabaseObserver.cpp
示例7: Dump
void WorkerDebuggerGlobalScope::Dump(JSContext* aCx,
const Optional<nsAString>& aString) const {
WorkerGlobalScope* scope = mWorkerPrivate->GetOrCreateGlobalScope(aCx);
if (scope) {
scope->Dump(aString);
}
}
示例8: performTask
virtual void performTask(ScriptExecutionContext *context)
{
ASSERT_WITH_SECURITY_IMPLICATION(context->isWorkerGlobalScope());
WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(context);
// Notify parent that this context is closed. Parent is responsible for calling WorkerThread::stop().
workerGlobalScope->thread()->workerReportingProxy().workerGlobalScopeClosed();
}
示例9: toWorkerGlobalScope
void WebSharedWorkerImpl::connectTask(PassOwnPtr<WebMessagePortChannel> channel, ExecutionContext* context)
{
// Wrap the passed-in channel in a MessagePort, and send it off via a connect event.
MessagePort* port = MessagePort::create(*context);
port->entangle(channel);
WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScope());
workerGlobalScope->dispatchEvent(createConnectEvent(port));
}
示例10: toWorkerGlobalScope
void MemoryCache::removeURLFromCache(ExecutionContext* context, const KURL& url)
{
if (context->isWorkerGlobalScope()) {
WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
workerGlobalScope->thread()->workerLoaderProxy().postTaskToLoader(createCallbackTask(&removeURLFromCacheInternal, url));
return;
}
removeURLFromCacheInternal(context, url);
}
示例11: toWorkerGlobalScope
void WebSharedWorkerImpl::connectTask(WebMessagePortChannelUniquePtr channel,
ExecutionContext* context) {
// Wrap the passed-in channel in a MessagePort, and send it off via a connect
// event.
MessagePort* port = MessagePort::create(*context);
port->entangle(std::move(channel));
WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
SECURITY_DCHECK(workerGlobalScope->isSharedWorkerGlobalScope());
workerGlobalScope->dispatchEvent(createConnectEvent(port));
}
示例12: GetGlobal
void WorkerDebuggerGlobalScope::GetGlobal(JSContext* aCx,
JS::MutableHandle<JSObject*> aGlobal,
ErrorResult& aRv) {
WorkerGlobalScope* scope = mWorkerPrivate->GetOrCreateGlobalScope(aCx);
if (!scope) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
aGlobal.set(scope->GetWrapper());
}
示例13: performTask
virtual void performTask(ScriptExecutionContext* scriptContext)
{
RefPtr<MessagePort> port = MessagePort::create(*scriptContext);
port->entangle(m_channel.release());
ASSERT_WITH_SECURITY_IMPLICATION(scriptContext->isWorkerGlobalScope());
WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(scriptContext);
// Since close() stops the thread event loop, this should not ever get called while closing.
ASSERT(!workerGlobalScope->isClosing());
ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScope());
workerGlobalScope->dispatchEvent(createConnectEvent(port));
}
示例14: SharedWorkerConnectTask
SharedWorkerConnectTask(MessagePortChannel* channel)
: ScriptExecutionContext::Task([=] (ScriptExecutionContext& context) {
RefPtr<MessagePort> port = MessagePort::create(context);
port->entangle(std::unique_ptr<MessagePortChannel>(channel));
ASSERT_WITH_SECURITY_IMPLICATION(context.isWorkerGlobalScope());
WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(&context);
// Since close() stops the thread event loop, this should not ever get called while closing.
ASSERT(!workerGlobalScope->isClosing());
ASSERT_WITH_SECURITY_IMPLICATION(workerGlobalScope->isSharedWorkerGlobalScope());
workerGlobalScope->dispatchEvent(createConnectEvent(port));
})
{
}
示例15: controllerForContext
WorkerScriptController* WorkerScriptController::controllerForContext(v8::Isolate* isolate)
{
// Happens on frame destruction, check otherwise GetCurrent() will crash.
if (!isolate || !isolate->InContext())
return 0;
v8::Handle<v8::Context> context = isolate->GetCurrentContext();
v8::Handle<v8::Object> global = context->Global();
global = global->FindInstanceInPrototypeChain(V8WorkerGlobalScope::domTemplate(isolate, WorkerWorld));
// Return 0 if the current executing context is not the worker context.
if (global.IsEmpty())
return 0;
WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global);
return workerGlobalScope->script();
}