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

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

Issue 1510603005: [Do not submit] Worklet implementation. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A basic CompositorWorklet implementation. Created 5 years 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..a01286e34e79a228fb4aa7e32de331d94add3740
--- /dev/null
+++ b/third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.cpp
@@ -0,0 +1,102 @@
+// Copyright 2015 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 "config.h"
+#include "modules/worklet/WorkletGlobalScope.h"
+
+#include "bindings/modules/v8/WorkletScriptController.h"
+#include "core/events/EventQueue.h"
+#include "platform/weborigin/KURL.h"
+
+namespace blink {
+
+namespace {
+
+// Worklets don't have an event queue which does anything. Inheriting
+// from ExecutionContext requires an EventQueue so we just create one than will
+// assert that it's not called.
+class WorkletEventQueue final : public EventQueue {
+public:
+ WorkletEventQueue() { }
+ ~WorkletEventQueue() override { }
+ bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) override { return false; } // XXX ASSERT NOT REACHED?
+ bool cancelEvent(Event*) override { return false; } // XXX ASSERT NOT REACHED
+ void close() override { }
+};
+
+} // namespace
+
+// static
+PassRefPtrWillBeRawPtr<WorkletGlobalScope> WorkletGlobalScope::create(v8::Isolate* isolate)
+{
+ return adoptRefWillBeNoop(new WorkletGlobalScope(isolate));
+}
+
+WorkletGlobalScope::WorkletGlobalScope(v8::Isolate* isolate)
+ : m_url(KURL())
+ , m_isolate(isolate)
+ , m_script(WorkletScriptController::create(this, m_isolate))
+ , m_queue(adoptPtrWillBeNoop(new WorkletEventQueue()))
+{
+}
+
+WorkletGlobalScope::~WorkletGlobalScope()
+{
+}
+
+GlobalScopeScriptController* WorkletGlobalScope::script()
+{
+ m_script->initializeContextIfNeeded();
+ return m_script.get();
+}
+
+v8::Local<v8::Object> WorkletGlobalScope::wrap(v8::Isolate*, v8::Local<v8::Object> creationContext) // XXX move to AbstractGlobalScope
+{
+ // 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) // XXX move to AbstractGlobalScope
+{
+ RELEASE_ASSERT_NOT_REACHED(); // same as wrap method
+ return v8::Local<v8::Object>();
+}
+
+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. Once we have a need for a real
+ // |isSecureContext| check here, we can check the responsible
+ // document for a privileged context at worker creation time, pass
+ // it in via WorkerThreadStartupData, and check it here.
+ return securityOrigin()->isPotentiallyTrustworthy(errorMessage);
+}
+
+const KURL& WorkletGlobalScope::virtualURL() const
+{
+ return m_url;
+}
+
+KURL WorkletGlobalScope::virtualCompleteURL(const String& url) const
+{
+ // Always return a null URL when passed a null string.
+ // FIXME: Should we change the KURL constructor to have this behavior?
+ if (url.isNull())
+ return KURL();
+ // Always use UTF-8 in Workers.
+ return KURL(m_url, url);
+}
+
+DEFINE_TRACE(WorkletGlobalScope)
+{
+#if ENABLE(OILPAN)
+ visitor->trace(m_queue);
+#endif
+ AbstractGlobalScope::trace(visitor);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698