本文整理汇总了C++中ExecutionContext::isWorkerGlobalScope方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecutionContext::isWorkerGlobalScope方法的具体用法?C++ ExecutionContext::isWorkerGlobalScope怎么用?C++ ExecutionContext::isWorkerGlobalScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext::isWorkerGlobalScope方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadResourceSynchronously
void ThreadableLoader::loadResourceSynchronously(ExecutionContext& context, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions)
{
if (context.isWorkerGlobalScope()) {
WorkerThreadableLoader::loadResourceSynchronously(toWorkerGlobalScope(context), request, client, options, resourceLoaderOptions);
return;
}
DocumentThreadableLoader::loadResourceSynchronously(toDocument(context), request, client, options, resourceLoaderOptions);
}
示例2: create
PassOwnPtr<ThreadableLoader> ThreadableLoader::create(ExecutionContext& context, ThreadableLoaderClient* client, const ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions)
{
ASSERT(client);
if (context.isWorkerGlobalScope()) {
return WorkerThreadableLoader::create(toWorkerGlobalScope(context), client, options, resourceLoaderOptions);
}
return DocumentThreadableLoader::create(toDocument(context), client, options, resourceLoaderOptions);
}
示例3: isScriptControllerTerminating
bool ActiveDOMCallback::isScriptControllerTerminating() const
{
ExecutionContext* context = executionContext();
if (context && context->isWorkerGlobalScope()) {
WorkerScriptController* scriptController = toWorkerGlobalScope(context)->script();
if (!scriptController || scriptController->isExecutionForbidden() || scriptController->isExecutionTerminating())
return true;
}
return false;
}
示例4: loadSynchronously
void WorkerScriptLoader::loadSynchronously(ExecutionContext& executionContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy, WebAddressSpace creationAddressSpace)
{
m_url = url;
ResourceRequest request(createResourceRequest(creationAddressSpace));
SECURITY_DCHECK(executionContext.isWorkerGlobalScope());
ThreadableLoaderOptions options;
options.crossOriginRequestPolicy = crossOriginRequestPolicy;
// FIXME: Should we add EnforceScriptSrcDirective here?
options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPolicy;
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.allowCredentials = AllowStoredCredentials;
WorkerThreadableLoader::loadResourceSynchronously(toWorkerGlobalScope(executionContext), request, *this, options, resourceLoaderOptions);
}
示例5: promiseRejectHandlerInWorker
static void promiseRejectHandlerInWorker(v8::PromiseRejectMessage data)
{
v8::Local<v8::Promise> promise = data.GetPromise();
// Bail out if called during context initialization.
v8::Isolate* isolate = promise->GetIsolate();
ScriptState* scriptState = ScriptState::current(isolate);
if (!scriptState->contextIsValid())
return;
ExecutionContext* executionContext = scriptState->executionContext();
if (!executionContext)
return;
ASSERT(executionContext->isWorkerGlobalScope());
WorkerScriptController* scriptController = toWorkerGlobalScope(executionContext)->script();
ASSERT(scriptController);
if (data.GetEvent() == v8::kPromiseHandlerAddedAfterReject) {
scriptController->rejectedPromises()->handlerAdded(data);
return;
}
ASSERT(data.GetEvent() == v8::kPromiseRejectWithNoHandler);
int scriptId = 0;
int lineNumber = 0;
int columnNumber = 0;
String resourceName;
String errorMessage;
v8::Local<v8::Message> message = v8::Exception::CreateMessage(data.GetValue());
if (!message.IsEmpty()) {
TOSTRING_VOID(V8StringResource<>, resourceName, message->GetScriptOrigin().ResourceName());
scriptId = message->GetScriptOrigin().ScriptID()->Value();
if (v8Call(message->GetLineNumber(scriptState->context()), lineNumber)
&& v8Call(message->GetStartColumn(scriptState->context()), columnNumber))
++columnNumber;
// message->Get() can be empty here. https://crbug.com/450330
errorMessage = toCoreStringWithNullCheck(message->Get());
}
scriptController->rejectedPromises()->rejectedWithNoHandler(scriptState, data, errorMessage, resourceName, scriptId, lineNumber, columnNumber, nullptr);
}
示例6: promiseRejectHandlerInWorker
static void promiseRejectHandlerInWorker(v8::PromiseRejectMessage data)
{
v8::Local<v8::Promise> promise = data.GetPromise();
// Bail out if called during context initialization.
v8::Isolate* isolate = promise->GetIsolate();
ScriptState* scriptState = ScriptState::current(isolate);
if (!scriptState->contextIsValid())
return;
ExecutionContext* executionContext = scriptState->getExecutionContext();
if (!executionContext)
return;
ASSERT(executionContext->isWorkerGlobalScope());
WorkerOrWorkletScriptController* scriptController = toWorkerGlobalScope(executionContext)->scriptController();
ASSERT(scriptController);
promiseRejectHandler(data, *scriptController->getRejectedPromises(), scriptState);
}
示例7: loadSynchronously
void WorkerScriptLoader::loadSynchronously(ExecutionContext& executionContext, const KURL& url, CrossOriginRequestPolicy crossOriginRequestPolicy)
{
m_url = url;
OwnPtr<ResourceRequest> request(createResourceRequest());
if (!request)
return;
ASSERT_WITH_SECURITY_IMPLICATION(executionContext.isWorkerGlobalScope());
ThreadableLoaderOptions options;
options.crossOriginRequestPolicy = crossOriginRequestPolicy;
// FIXME: Should we add EnforceScriptSrcDirective here?
options.contentSecurityPolicyEnforcement = DoNotEnforceContentSecurityPolicy;
ResourceLoaderOptions resourceLoaderOptions;
resourceLoaderOptions.allowCredentials = AllowStoredCredentials;
WorkerThreadableLoader::loadResourceSynchronously(toWorkerGlobalScope(executionContext), *request, *this, options, resourceLoaderOptions);
}