| Index: third_party/WebKit/Source/core/workers/WorkletGlobalScopeManager.cpp
|
| diff --git a/third_party/WebKit/Source/core/workers/WorkletGlobalScopeManager.cpp b/third_party/WebKit/Source/core/workers/WorkletGlobalScopeManager.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..576d4a3a55297e06cb9bd0712018bce0e23e5e63
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/workers/WorkletGlobalScopeManager.cpp
|
| @@ -0,0 +1,41 @@
|
| +// 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.
|
| +
|
| +#include "core/workers/WorkletGlobalScopeManager.h"
|
| +
|
| +#include "core/workers/WorkletPendingTasks.h"
|
| +
|
| +namespace blink {
|
| +
|
| +void WorkletGlobalScopeManager::AddGlobalScope(
|
| + std::unique_ptr<WorkletGlobalScopeProxy> proxy) {
|
| + proxies_.insert(std::move(proxy));
|
| +}
|
| +
|
| +WorkletGlobalScopeProxy* WorkletGlobalScopeManager::FindAvailableGlobalScope()
|
| + const {
|
| + DCHECK(IsMainThread());
|
| + // TODO(nhiroki): Support the case where there are multiple global scopes.
|
| + DCHECK_EQ(1u, GetNumberOfGlobalScopes());
|
| + return proxies_.begin()->get();
|
| +}
|
| +
|
| +void WorkletGlobalScopeManager::AddModuleToGlobalScopes(
|
| + const KURL& module_url_record,
|
| + WebURLRequest::FetchCredentialsMode credentials_mode,
|
| + WorkletPendingTasks* pending_tasks) {
|
| + DCHECK(IsMainThread());
|
| + for (const auto& proxy : proxies_) {
|
| + proxy->FetchAndInvokeScript(module_url_record, credentials_mode,
|
| + pending_tasks);
|
| + }
|
| +}
|
| +
|
| +void WorkletGlobalScopeManager::TerminateGlobalScopes() {
|
| + DCHECK(IsMainThread());
|
| + for (const auto& proxy : proxies_)
|
| + proxy->TerminateWorkletGlobalScope();
|
| +}
|
| +
|
| +} // namespace blink
|
|
|