Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 ParentFrameTaskRunners* task_runners, | |
| 13 WorkletPendingTasks* pending_tasks) | 16 WorkletPendingTasks* pending_tasks) |
| 14 : modulator_(modulator), pending_tasks_(pending_tasks) {} | 17 : modulator_(modulator), |
| 18 task_runners_(task_runners), | |
| 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(). |
|
kinuko
2017/05/30 02:32:58
The spec seems to say 'responsible event loop' is
nhiroki
2017/05/30 04:03:40
According to [1], "workletEventLoop" is the messag
| |
| 26 // TODO(nhiroki): Queue a task instead of executing this here. | 30 task_runners_->Get(TaskType::kUnspecedLoading) |
| 27 pending_tasks_->Abort(); | 31 ->PostTask( |
| 32 BLINK_FROM_HERE, | |
| 33 CrossThreadBind(&WorkletPendingTasks::Abort, | |
| 34 WrapCrossThreadPersistent(pending_tasks_.Get()))); | |
| 28 return; | 35 return; |
| 29 } | 36 } |
| 30 | 37 |
| 31 // Step 4: "Run a module script given script." | 38 // Step 4: "Run a module script given script." |
| 32 modulator_->ExecuteModule(module_script); | 39 modulator_->ExecuteModule(module_script); |
| 33 | 40 |
| 34 // Step 5: "Queue a task on outsideSettings's responsible event loop to run | 41 // Step 5: "Queue a task on outsideSettings's responsible event loop to run |
| 35 // these steps:" | 42 // these steps:" |
| 36 // The steps are implemented in WorkletPendingTasks::DecrementCounter(). | 43 // The steps are implemented in WorkletPendingTasks::DecrementCounter(). |
| 37 // TODO(nhiroki): Queue a task instead of executing this here. | 44 task_runners_->Get(TaskType::kUnspecedLoading) |
| 38 pending_tasks_->DecrementCounter(); | 45 ->PostTask( |
| 46 BLINK_FROM_HERE, | |
| 47 CrossThreadBind(&WorkletPendingTasks::DecrementCounter, | |
| 48 WrapCrossThreadPersistent(pending_tasks_.Get()))); | |
| 39 }; | 49 }; |
| 40 | 50 |
| 41 DEFINE_TRACE(WorkletModuleTreeClient) { | 51 DEFINE_TRACE(WorkletModuleTreeClient) { |
| 42 visitor->Trace(modulator_); | 52 visitor->Trace(modulator_); |
| 43 visitor->Trace(pending_tasks_); | |
| 44 ModuleTreeClient::Trace(visitor); | 53 ModuleTreeClient::Trace(visitor); |
| 45 } | 54 } |
| 46 | 55 |
| 47 } // namespace blink | 56 } // namespace blink |
| OLD | NEW |