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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 "config.h"
6 #include "modules/worklet/WorkletGlobalScope.h"
7
8 #include "bindings/modules/v8/WorkletScriptController.h"
9 #include "core/events/EventQueue.h"
10 #include "platform/weborigin/KURL.h"
11
12 namespace blink {
13
14 namespace {
15
16 // Worklets don't have an event queue which does anything. Inheriting
17 // from ExecutionContext requires an EventQueue so we just create one than will
18 // assert that it's not called.
19 class WorkletEventQueue final : public EventQueue {
20 public:
21 WorkletEventQueue() { }
22 ~WorkletEventQueue() override { }
23 bool enqueueEvent(PassRefPtrWillBeRawPtr<Event>) override { return false; } // XXX ASSERT NOT REACHED?
24 bool cancelEvent(Event*) override { return false; } // XXX ASSERT NOT REACHE D
25 void close() override { }
26 };
27
28 } // namespace
29
30 // static
31 PassRefPtrWillBeRawPtr<WorkletGlobalScope> WorkletGlobalScope::create(v8::Isolat e* isolate)
32 {
33 return adoptRefWillBeNoop(new WorkletGlobalScope(isolate));
34 }
35
36 WorkletGlobalScope::WorkletGlobalScope(v8::Isolate* isolate)
37 : m_url(KURL())
38 , m_isolate(isolate)
39 , m_script(WorkletScriptController::create(this, m_isolate))
40 , m_queue(adoptPtrWillBeNoop(new WorkletEventQueue()))
41 {
42 }
43
44 WorkletGlobalScope::~WorkletGlobalScope()
45 {
46 }
47
48 GlobalScopeScriptController* WorkletGlobalScope::script()
49 {
50 m_script->initializeContextIfNeeded();
51 return m_script.get();
52 }
53
54 v8::Local<v8::Object> WorkletGlobalScope::wrap(v8::Isolate*, v8::Local<v8::Objec t> creationContext) // XXX move to AbstractGlobalScope
55 {
56 // WorkletGlobalScope must never be wrapped with wrap method. The global
57 // object of ECMAScript environment is used as the wrapper.
58 RELEASE_ASSERT_NOT_REACHED();
59 return v8::Local<v8::Object>();
60 }
61
62 v8::Local<v8::Object> WorkletGlobalScope::associateWithWrapper(v8::Isolate*, con st WrapperTypeInfo*, v8::Local<v8::Object> wrapper) // XXX move to AbstractGloba lScope
63 {
64 RELEASE_ASSERT_NOT_REACHED(); // same as wrap method
65 return v8::Local<v8::Object>();
66 }
67
68 bool WorkletGlobalScope::isSecureContext(String& errorMessage, const SecureConte xtCheck privilegeContextCheck) const
69 {
70 // Until there are APIs that are available in worklets and that
71 // require a privileged context test that checks ancestors, just do
72 // a simple check here. Once we have a need for a real
73 // |isSecureContext| check here, we can check the responsible
74 // document for a privileged context at worker creation time, pass
75 // it in via WorkerThreadStartupData, and check it here.
76 return securityOrigin()->isPotentiallyTrustworthy(errorMessage);
77 }
78
79 const KURL& WorkletGlobalScope::virtualURL() const
80 {
81 return m_url;
82 }
83
84 KURL WorkletGlobalScope::virtualCompleteURL(const String& url) const
85 {
86 // Always return a null URL when passed a null string.
87 // FIXME: Should we change the KURL constructor to have this behavior?
88 if (url.isNull())
89 return KURL();
90 // Always use UTF-8 in Workers.
91 return KURL(m_url, url);
92 }
93
94 DEFINE_TRACE(WorkletGlobalScope)
95 {
96 #if ENABLE(OILPAN)
97 visitor->trace(m_queue);
98 #endif
99 AbstractGlobalScope::trace(visitor);
100 }
101
102 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698