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

Side by Side Diff: third_party/WebKit/Source/core/workers/WorkletPendingTasks.h

Issue 2839123003: Worklet: Introduce "pending tasks struct" concept defined in the Worklet spec (Closed)
Patch Set: address review 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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698