OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WorkletPendingTasks_h |
| 6 #define WorkletPendingTasks_h |
| 7 |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "platform/heap/Heap.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 // Implementation of the "pending tasks struct": |
| 14 // https://drafts.css-houdini.org/worklets/#pending-tasks-struct |
| 15 // |
| 16 // This also implements a part of the "fetch and invoke a worklet script" |
| 17 // algorithm: |
| 18 // https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script |
| 19 // |
| 20 // All functions must be accessed on the main thread. |
| 21 class WorkletPendingTasks final : public GarbageCollected<WorkletPendingTasks> { |
| 22 public: |
| 23 WorkletPendingTasks(int counter, ScriptPromiseResolver*); |
| 24 |
| 25 // Sets |counter_| to -1 and rejects the promise. |
| 26 void Abort(); |
| 27 |
| 28 // Decrements |counter_| and resolves the promise if the counter becomes 0. |
| 29 void DecrementCounter(); |
| 30 |
| 31 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->Trace(resolver_); } |
| 32 |
| 33 private: |
| 34 // The number of pending tasks. -1 indicates these tasks are aborted and |
| 35 // |resolver_| already rejected the promise. |
| 36 int counter_; |
| 37 |
| 38 Member<ScriptPromiseResolver> resolver_; |
| 39 }; |
| 40 |
| 41 } // namespace blink |
| 42 |
| 43 #endif // WorkletPendingTasks_h |
OLD | NEW |