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

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

Issue 2171563002: Add WorkerSettings to expose certain flag values in WorkerGlobalScope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added expected Created 4 years, 5 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/WorkerSettings.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkerSettings.cpp b/third_party/WebKit/Source/core/workers/WorkerSettings.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..80bdedc840b077b9bbe690b2afd8cf8c9a129b65
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/WorkerSettings.cpp
@@ -0,0 +1,47 @@
+// Copyright 2016 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/WorkerSettings.h"
+
+#include "core/workers/WorkerGlobalScope.h"
+
+namespace blink {
+
+const char* WorkerSettings::supplementName()
+{
+ return "WorkerSettings";
+}
+
+WorkerSettings* WorkerSettings::create(Settings* settings)
+{
+ WorkerSettings* workerSettings = new WorkerSettings();
+ workerSettings->copyFlagValuesFromSettings(settings);
+ return workerSettings;
+}
+
+WorkerSettings* WorkerSettings::from(ExecutionContext* context)
kinuko 2016/07/22 09:02:54 I'm not sure if we should pass this as a supplemen
xlai (Olivia) 2016/07/22 21:53:30 I did think of making WorkerSetting to become a me
nhiroki 2016/07/25 11:14:48 I'd prefer to pass it via WorkerThreadStartupData.
+{
+ if (context->isWorkerGlobalScope()) {
+ WorkerClients* clients = toWorkerGlobalScope(*context).clients();
+ DCHECK(clients);
+ return static_cast<WorkerSettings*>(Supplement<WorkerClients>::from(clients, supplementName()));
+ }
+ return nullptr;
+}
+
+void WorkerSettings::copyFlagValuesFromSettings(Settings* settings)
+{
+ m_disableReadingFromCanvas = settings->disableReadingFromCanvas();
+}
+
+void provideWorkerSettingsToWorker(WorkerClients* clients, WorkerSettings* client)
+{
+ clients->provideSupplement(WorkerSettings::supplementName(), client);
+}
+
+DEFINE_TRACE(WorkerSettings)
+{
+ Supplement<WorkerClients>::trace(visitor);
+}
+}
kinuko 2016/07/22 09:02:54 ditto
xlai (Olivia) 2016/07/22 21:53:30 Done.

Powered by Google App Engine
This is Rietveld 408576698