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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/workers/WorkletModuleTreeClient.h" 5 #include "core/workers/WorkletModuleTreeClient.h"
6 6
7 #include "core/dom/ModuleScript.h" 7 #include "core/dom/ModuleScript.h"
8 #include "core/dom/TaskRunnerHelper.h"
9 #include "platform/CrossThreadFunctional.h"
8 10
9 namespace blink { 11 namespace blink {
10 12
11 WorkletModuleTreeClient::WorkletModuleTreeClient( 13 WorkletModuleTreeClient::WorkletModuleTreeClient(
12 Modulator* modulator, 14 Modulator* modulator,
15 RefPtr<WebTaskRunner> parent_frame_task_runner,
13 WorkletPendingTasks* pending_tasks) 16 WorkletPendingTasks* pending_tasks)
14 : modulator_(modulator), pending_tasks_(pending_tasks) {} 17 : modulator_(modulator),
18 parent_frame_task_runner_(std::move(parent_frame_task_runner)),
19 pending_tasks_(pending_tasks) {}
15 20
16 // Implementation of the second half of the "fetch and invoke a worklet script" 21 // Implementation of the second half of the "fetch and invoke a worklet script"
17 // algorithm: 22 // algorithm:
18 // https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script 23 // https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script
19 void WorkletModuleTreeClient::NotifyModuleTreeLoadFinished( 24 void WorkletModuleTreeClient::NotifyModuleTreeLoadFinished(
20 ModuleScript* module_script) { 25 ModuleScript* module_script) {
21 DCHECK(IsMainThread());
22 if (!module_script) { 26 if (!module_script) {
23 // Step 3: "If script is null, then queue a task on outsideSettings's 27 // Step 3: "If script is null, then queue a task on outsideSettings's
24 // responsible event loop to run these steps:" 28 // responsible event loop to run these steps:"
25 // The steps are implemented in WorkletPendingTasks::Abort(). 29 // The steps are implemented in WorkletPendingTasks::Abort().
26 // TODO(nhiroki): Queue a task instead of executing this here. 30 parent_frame_task_runner_->PostTask(
27 pending_tasks_->Abort(); 31 BLINK_FROM_HERE,
32 CrossThreadBind(&WorkletPendingTasks::Abort,
33 WrapCrossThreadPersistent(pending_tasks_.Get())));
28 return; 34 return;
29 } 35 }
30 36
31 // Step 4: "Run a module script given script." 37 // Step 4: "Run a module script given script."
32 modulator_->ExecuteModule(module_script); 38 modulator_->ExecuteModule(module_script);
33 39
34 // Step 5: "Queue a task on outsideSettings's responsible event loop to run 40 // Step 5: "Queue a task on outsideSettings's responsible event loop to run
35 // these steps:" 41 // these steps:"
36 // The steps are implemented in WorkletPendingTasks::DecrementCounter(). 42 // The steps are implemented in WorkletPendingTasks::DecrementCounter().
37 // TODO(nhiroki): Queue a task instead of executing this here. 43 parent_frame_task_runner_->PostTask(
38 pending_tasks_->DecrementCounter(); 44 BLINK_FROM_HERE,
45 CrossThreadBind(&WorkletPendingTasks::DecrementCounter,
46 WrapCrossThreadPersistent(pending_tasks_.Get())));
39 }; 47 };
40 48
41 DEFINE_TRACE(WorkletModuleTreeClient) { 49 DEFINE_TRACE(WorkletModuleTreeClient) {
42 visitor->Trace(modulator_); 50 visitor->Trace(modulator_);
43 visitor->Trace(pending_tasks_);
44 ModuleTreeClient::Trace(visitor); 51 ModuleTreeClient::Trace(visitor);
45 } 52 }
46 53
47 } // namespace blink 54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698