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

Unified Diff: third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.cpp

Issue 1535943005: Initial implementation of bindings and basic classes for worklets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments. Created 4 years, 11 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/modules/worklet/WorkletGlobalScope.cpp
diff --git a/third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.cpp b/third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..976466742063d4cc5457dda5db97d64624f496fb
--- /dev/null
+++ b/third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.cpp
@@ -0,0 +1,72 @@
+// 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 "modules/worklet/WorkletGlobalScope.h"
+
+#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
+
+namespace blink {
+
+// static
+PassRefPtrWillBeRawPtr<WorkletGlobalScope> WorkletGlobalScope::create(const KURL& url, const String& userAgent, v8::Isolate* isolate)
+{
+ return adoptRefWillBeNoop(new WorkletGlobalScope(url, userAgent, isolate));
+}
+
+WorkletGlobalScope::WorkletGlobalScope(const KURL& url, const String& userAgent, v8::Isolate* isolate)
+ : m_script(WorkerOrWorkletScriptController::create(this, isolate))
+{
+ m_script->initializeContextIfNeeded();
+}
+
+WorkletGlobalScope::~WorkletGlobalScope()
+{
+}
+
+v8::Local<v8::Object> WorkletGlobalScope::wrap(v8::Isolate*, v8::Local<v8::Object> creationContext)
+{
+ // WorkletGlobalScope must never be wrapped with wrap method. The global
+ // object of ECMAScript environment is used as the wrapper.
+ RELEASE_ASSERT_NOT_REACHED();
+ return v8::Local<v8::Object>();
+}
+
+v8::Local<v8::Object> WorkletGlobalScope::associateWithWrapper(v8::Isolate*, const WrapperTypeInfo*, v8::Local<v8::Object> wrapper)
+{
+ RELEASE_ASSERT_NOT_REACHED(); // same as wrap method
kinuko 2016/01/13 02:59:20 nit: this is probably just copy-pasted, but let's
+ return v8::Local<v8::Object>();
+}
+
+void WorkletGlobalScope::disableEval(const String& errorMessage)
+{
+ m_script->disableEval(errorMessage);
+}
+
+bool WorkletGlobalScope::isSecureContext(String& errorMessage, const SecureContextCheck privilegeContextCheck) const
+{
+ // Until there are APIs that are available in worklets and that
+ // require a privileged context test that checks ancestors, just do
+ // a simple check here.
+ return securityOrigin()->isPotentiallyTrustworthy(errorMessage);
+}
+
+KURL WorkletGlobalScope::virtualCompleteURL(const String& url) const
+{
+ // Always return a null URL when passed a null string.
+ // FIXME(ikilpatrick): Should we change the KURL constructor to have this
kinuko 2016/01/13 02:59:20 FIXME -> TODO (per our new guideline)?
ikilpatrick 2016/01/13 04:12:29 Done.
+ // behavior?
+ if (url.isNull())
+ return KURL();
+ // Always use UTF-8 in Worklets.
+ return KURL(m_url, url);
+}
+
+DEFINE_TRACE(WorkletGlobalScope)
+{
+ visitor->trace(m_script);
+ ExecutionContext::trace(visitor);
+ SecurityContext::trace(visitor);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698