Chromium Code Reviews| Index: third_party/WebKit/Source/core/workers/WorkletGlobalScopeManager.h |
| diff --git a/third_party/WebKit/Source/core/workers/WorkletGlobalScopeManager.h b/third_party/WebKit/Source/core/workers/WorkletGlobalScopeManager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..775cc054161cf81665d375ff55c8384018fa5f27 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/workers/WorkletGlobalScopeManager.h |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef WorkletGlobalScopeManager_h |
| +#define WorkletGlobalScopeManager_h |
| + |
| +#include <memory> |
| +#include "core/CoreExport.h" |
| +#include "core/workers/WorkletGlobalScopeProxy.h" |
| +#include "platform/heap/GarbageCollected.h" |
| +#include "public/platform/WebURLRequest.h" |
| + |
| +namespace blink { |
| + |
| +class WorkletPendingTasks; |
| + |
| +// Manages proxies to worklet global scopes on the main thread. Owned by the |
| +// Worklet class. |
| +class CORE_EXPORT WorkletGlobalScopeManager |
| + : public GarbageCollectedFinalized<WorkletGlobalScopeManager> { |
| + WTF_MAKE_NONCOPYABLE(WorkletGlobalScopeManager); |
| + |
| + public: |
| + WorkletGlobalScopeManager() = default; |
| + virtual ~WorkletGlobalScopeManager() = default; |
| + |
| + // Adds a global scope to the managed set. |
| + 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
|
| + |
| + // Returns one of available global scopes. |
| + WorkletGlobalScopeProxy* FindAvailableGlobalScope() const; |
| + |
| + // Fetches and evaluates module scripts on all global scopes. |
| + void AddModuleToGlobalScopes(const KURL& module_url_record, |
| + WebURLRequest::FetchCredentialsMode, |
| + WorkletPendingTasks*); |
| + |
| + // Terminates all global scopes. |
| + void TerminateGlobalScopes(); |
| + |
| + 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.
|
| + |
| + DEFINE_INLINE_TRACE() {} |
| + |
| + private: |
| + // "A Worklet has a list of the worklet's WorkletGlobalScopes. Initially this |
| + // list is empty; it is populated when the user agent chooses to create its |
| + // WorkletGlobalScope." |
| + // https://drafts.css-houdini.org/worklets/#worklet-section |
| + // TODO(nhiroki): Make (Paint)WorkletGlobalScopeProxy GC-managed object to |
| + // avoid that GC graphs are disjointed (https://crbug.com/719775). |
| + WTF::HashSet<std::unique_ptr<WorkletGlobalScopeProxy>> proxies_; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // WorkletGlobalScopeManager_h |