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 #include "core/workers/WorkletGlobalScopeManager.h" |
| 6 |
| 7 #include "core/workers/WorkletPendingTasks.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 void WorkletGlobalScopeManager::AddGlobalScope( |
| 12 std::unique_ptr<WorkletGlobalScopeProxy> proxy) { |
| 13 proxies_.insert(std::move(proxy)); |
| 14 } |
| 15 |
| 16 WorkletGlobalScopeProxy* WorkletGlobalScopeManager::FindAvailableGlobalScope() |
| 17 const { |
| 18 DCHECK(IsMainThread()); |
| 19 // TODO(nhiroki): Support the case where there are multiple global scopes. |
| 20 DCHECK_EQ(1u, GetNumberOfGlobalScopes()); |
| 21 return proxies_.begin()->get(); |
| 22 } |
| 23 |
| 24 void WorkletGlobalScopeManager::AddModuleToGlobalScopes( |
| 25 const KURL& module_url_record, |
| 26 WebURLRequest::FetchCredentialsMode credentials_mode, |
| 27 WorkletPendingTasks* pending_tasks) { |
| 28 DCHECK(IsMainThread()); |
| 29 for (const auto& proxy : proxies_) { |
| 30 proxy->FetchAndInvokeScript(module_url_record, credentials_mode, |
| 31 pending_tasks); |
| 32 } |
| 33 } |
| 34 |
| 35 void WorkletGlobalScopeManager::TerminateGlobalScopes() { |
| 36 DCHECK(IsMainThread()); |
| 37 for (const auto& proxy : proxies_) |
| 38 proxy->TerminateWorkletGlobalScope(); |
| 39 } |
| 40 |
| 41 } // namespace blink |
OLD | NEW |