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

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

Issue 2910953002: Worklet: Enqueue tasks into outsideSetting's event loop (Closed)
Patch Set: fix header inclusion 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..3b07b9073cf412f0cffa26e95cfde82bd4a68da5 100644
--- a/third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.cpp
@@ -5,26 +5,32 @@
#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,
+ RefPtr<WebTaskRunner> parent_frame_task_runner,
WorkletPendingTasks* pending_tasks)
- : modulator_(modulator), pending_tasks_(pending_tasks) {}
+ : modulator_(modulator),
+ parent_frame_task_runner_(std::move(parent_frame_task_runner)),
+ 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();
+ parent_frame_task_runner_->PostTask(
+ BLINK_FROM_HERE,
+ CrossThreadBind(&WorkletPendingTasks::Abort,
+ WrapCrossThreadPersistent(pending_tasks_.Get())));
return;
}
@@ -34,13 +40,14 @@ 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();
+ parent_frame_task_runner_->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