| Index: third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp
|
| diff --git a/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp b/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp
|
| index bb71248f0b1a58ae06bf54273ad6271724340cbb..0ab1759950b7a03feaa0e14acf316e155b42041b 100644
|
| --- a/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp
|
| +++ b/third_party/WebKit/Source/core/workers/MainThreadWorkletGlobalScope.cpp
|
| @@ -7,11 +7,15 @@
|
| #include "bindings/core/v8/ScriptSourceCode.h"
|
| #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
|
| #include "core/dom/Document.h"
|
| +#include "core/dom/Modulator.h"
|
| #include "core/frame/Deprecation.h"
|
| #include "core/frame/FrameConsole.h"
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/inspector/MainThreadDebugger.h"
|
| +#include "core/loader/modulescript/ModuleScriptFetchRequest.h"
|
| #include "core/probe/CoreProbes.h"
|
| +#include "core/workers/WorkletModuleTreeClient.h"
|
| +#include "public/platform/WebURLRequest.h"
|
|
|
| namespace blink {
|
|
|
| @@ -59,57 +63,24 @@ void MainThreadWorkletGlobalScope::FetchAndInvokeScript(
|
| // Step 2: "Let script by the result of fetch a worklet script given
|
| // moduleURLRecord, moduleResponsesMap, credentialOptions, outsideSettings,
|
| // and insideSettings when it asynchronously completes."
|
| - // TODO(nhiroki): Replace this with module script loading. Set fetch request's
|
| - // credentials mode to |credentials_mode|.
|
| - WorkletScriptLoader* script_loader =
|
| - WorkletScriptLoader::Create(GetFrame()->GetDocument()->Fetcher(), this);
|
| - loader_map_.Set(script_loader, pending_tasks);
|
| - script_loader->FetchScript(module_url_record);
|
| + String nonce = "";
|
| + ParserDisposition parser_state = kNotParserInserted;
|
| + Modulator* modulator = Modulator::From(ScriptController()->GetScriptState());
|
| + ModuleScriptFetchRequest module_request(module_url_record, nonce,
|
| + parser_state, credentials_mode);
|
| +
|
| + // Step 3 to 5 are implemented in
|
| + // WorkletModuleTreeClient::NotifyModuleTreeLoadFinished.
|
| + WorkletModuleTreeClient* client =
|
| + new WorkletModuleTreeClient(modulator, pending_tasks);
|
| + modulator->FetchTree(module_request, client);
|
| }
|
|
|
| // TODO(nhiroki): Add tests for termination.
|
| void MainThreadWorkletGlobalScope::Terminate() {
|
| - for (auto it = loader_map_.begin(); it != loader_map_.end();) {
|
| - WorkletScriptLoader* script_loader = it->key;
|
| - // Cancel() eventually calls NotifyWorkletScriptLoadingFinished() and
|
| - // removes |it| from |loader_map_|, so increment it in advance.
|
| - ++it;
|
| - script_loader->Cancel();
|
| - }
|
| Dispose();
|
| }
|
|
|
| -// Implementation of the second half of the "fetch and invoke a worklet script"
|
| -// algorithm:
|
| -// https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script
|
| -void MainThreadWorkletGlobalScope::NotifyWorkletScriptLoadingFinished(
|
| - WorkletScriptLoader* script_loader,
|
| - const ScriptSourceCode& source_code) {
|
| - DCHECK(IsMainThread());
|
| - auto it = loader_map_.find(script_loader);
|
| - DCHECK(it != loader_map_.end());
|
| - WorkletPendingTasks* pending_tasks = it->value;
|
| - loader_map_.erase(it);
|
| -
|
| - if (!script_loader->WasScriptLoadSuccessful()) {
|
| - // Step 3: "If script is null, then queue a task on outsideSettings's
|
| - // responsible event loop to run these steps:"
|
| - // The steps are implemented in WorkletPendingTasks::Abort().
|
| - // TODO(nhiroki): Queue a task instead of executing this here.
|
| - pending_tasks->Abort();
|
| - return;
|
| - }
|
| -
|
| - // Step 4: "Run a module script given script."
|
| - ScriptController()->Evaluate(source_code);
|
| -
|
| - // Step 5: "Queue a task on outsideSettings's responsible event loop to run
|
| - // these steps:"
|
| - // The steps are implemented in WorkletPendingTasks::DecrementCounter().
|
| - // TODO(nhiroki): Queue a task instead of executing this here.
|
| - pending_tasks->DecrementCounter();
|
| -}
|
| -
|
| void MainThreadWorkletGlobalScope::AddConsoleMessage(
|
| ConsoleMessage* console_message) {
|
| GetFrame()->Console().AddMessage(console_message);
|
| @@ -124,7 +95,6 @@ CoreProbeSink* MainThreadWorkletGlobalScope::GetProbeSink() {
|
| }
|
|
|
| DEFINE_TRACE(MainThreadWorkletGlobalScope) {
|
| - visitor->Trace(loader_map_);
|
| WorkletGlobalScope::Trace(visitor);
|
| ContextClient::Trace(visitor);
|
| }
|
|
|