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 WorkletGlobalScopeManager_h | |
6 #define WorkletGlobalScopeManager_h | |
7 | |
8 #include <memory> | |
9 #include "core/CoreExport.h" | |
10 #include "core/workers/WorkletGlobalScopeProxy.h" | |
11 #include "platform/heap/GarbageCollected.h" | |
12 #include "public/platform/WebURLRequest.h" | |
13 | |
14 namespace blink { | |
15 | |
16 class WorkletPendingTasks; | |
17 | |
18 // Manages proxies to worklet global scopes on the main thread. Owned by the | |
19 // Worklet class. | |
20 class CORE_EXPORT WorkletGlobalScopeManager | |
21 : public GarbageCollectedFinalized<WorkletGlobalScopeManager> { | |
22 WTF_MAKE_NONCOPYABLE(WorkletGlobalScopeManager); | |
23 | |
24 public: | |
25 WorkletGlobalScopeManager() = default; | |
26 virtual ~WorkletGlobalScopeManager() = default; | |
27 | |
28 // Adds a global scope to the managed set. | |
29 void AddGlobalScope(std::unique_ptr<WorkletGlobalScopeProxy>); | |
kinuko
2017/05/24 06:53:40
nit: it looks we can remove 'GlobalScope' part fro
nhiroki
2017/05/24 08:11:22
The latest patchset removed this and other functio
| |
30 | |
31 // Returns one of available global scopes. | |
32 WorkletGlobalScopeProxy* FindAvailableGlobalScope() const; | |
33 | |
34 // Fetches and evaluates module scripts on all global scopes. | |
35 void AddModuleToGlobalScopes(const KURL& module_url_record, | |
36 WebURLRequest::FetchCredentialsMode, | |
37 WorkletPendingTasks*); | |
38 | |
39 // Terminates all global scopes. | |
40 void TerminateGlobalScopes(); | |
41 | |
42 size_t GetNumberOfGlobalScopes() const { return proxies_.size(); } | |
kinuko
2017/05/24 06:53:39
It looks we can also simply let MainThreadWorklet
nhiroki
2017/05/24 08:11:22
Done.
| |
43 | |
44 DEFINE_INLINE_TRACE() {} | |
45 | |
46 private: | |
47 // "A Worklet has a list of the worklet's WorkletGlobalScopes. Initially this | |
48 // list is empty; it is populated when the user agent chooses to create its | |
49 // WorkletGlobalScope." | |
50 // https://drafts.css-houdini.org/worklets/#worklet-section | |
51 // TODO(nhiroki): Make (Paint)WorkletGlobalScopeProxy GC-managed object to | |
52 // avoid that GC graphs are disjointed (https://crbug.com/719775). | |
53 WTF::HashSet<std::unique_ptr<WorkletGlobalScopeProxy>> proxies_; | |
54 }; | |
55 | |
56 } // namespace blink | |
57 | |
58 #endif // WorkletGlobalScopeManager_h | |
OLD | NEW |