Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(736)

Unified Diff: third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.cpp

Issue 2910953002: Worklet: Enqueue tasks into outsideSetting's event loop (Closed)
Patch Set: fix Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.cpp b/third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.cpp
index 829ecd52081120cf4cd53f150332206e0d3460d3..132368ac3cf6355c0b6aed2676870369bebca281 100644
--- a/third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.cpp
@@ -5,26 +5,33 @@
#include "core/workers/WorkletModuleTreeClient.h"
#include "core/dom/ModuleScript.h"
+#include "core/dom/TaskRunnerHelper.h"
+#include "platform/CrossThreadFunctional.h"
namespace blink {
WorkletModuleTreeClient::WorkletModuleTreeClient(
Modulator* modulator,
+ ParentFrameTaskRunners* task_runners,
WorkletPendingTasks* pending_tasks)
- : modulator_(modulator), pending_tasks_(pending_tasks) {}
+ : modulator_(modulator),
+ task_runners_(task_runners),
+ pending_tasks_(pending_tasks) {}
// 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 WorkletModuleTreeClient::NotifyModuleTreeLoadFinished(
ModuleScript* module_script) {
- DCHECK(IsMainThread());
if (!module_script) {
// 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();
+ task_runners_->Get(TaskType::kUnspecedLoading)
+ ->PostTask(
+ BLINK_FROM_HERE,
+ CrossThreadBind(&WorkletPendingTasks::Abort,
+ WrapCrossThreadPersistent(pending_tasks_.Get())));
return;
}
@@ -34,13 +41,15 @@ void WorkletModuleTreeClient::NotifyModuleTreeLoadFinished(
// 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();
+ task_runners_->Get(TaskType::kUnspecedLoading)
+ ->PostTask(
+ BLINK_FROM_HERE,
+ CrossThreadBind(&WorkletPendingTasks::DecrementCounter,
+ WrapCrossThreadPersistent(pending_tasks_.Get())));
};
DEFINE_TRACE(WorkletModuleTreeClient) {
visitor->Trace(modulator_);
- visitor->Trace(pending_tasks_);
ModuleTreeClient::Trace(visitor);
}

Powered by Google App Engine
This is Rietveld 408576698