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

Unified Diff: third_party/WebKit/Source/core/workers/WorkletGlobalScopeManager.cpp

Issue 2871513002: Worklet: Lazily create PaintWorkletGlobalScopes (Closed)
Patch Set: clean up 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698