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

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

Issue 2826313003: Worklet: Enable module script loading for main thread worklets (Closed)
Patch Set: update comments 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
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..829ecd52081120cf4cd53f150332206e0d3460d3
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.cpp
@@ -0,0 +1,47 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/workers/WorkletModuleTreeClient.h"
+
+#include "core/dom/ModuleScript.h"
+
+namespace blink {
+
+WorkletModuleTreeClient::WorkletModuleTreeClient(
+ Modulator* modulator,
+ WorkletPendingTasks* pending_tasks)
+ : modulator_(modulator), 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();
+ return;
+ }
+
+ // Step 4: "Run a module script given script."
+ modulator_->ExecuteModule(module_script);
+
+ // 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();
+};
+
+DEFINE_TRACE(WorkletModuleTreeClient) {
+ visitor->Trace(modulator_);
+ visitor->Trace(pending_tasks_);
+ ModuleTreeClient::Trace(visitor);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkletModuleTreeClient.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698