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

Side by Side 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: address (most) 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 "modules/worklet/WorkletGlobalScope.h"
6
7 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
8
9 namespace blink {
10
11 // static
12 PassRefPtrWillBeRawPtr<WorkletGlobalScope> WorkletGlobalScope::create(const KURL & url, const String& userAgent, v8::Isolate* isolate)
13 {
14 return adoptRefWillBeNoop(new WorkletGlobalScope(url, userAgent, isolate));
15 }
16
17 WorkletGlobalScope::WorkletGlobalScope(const KURL& url, const String& userAgent, v8::Isolate* isolate)
18 : m_script(WorkerOrWorkletScriptController::create(this, this, isolate))
19 {
20 m_script->initializeContextIfNeeded();
haraken 2016/01/08 04:59:07 Now that you call this in WorkletGlobalScope's con
ikilpatrick 2016/01/11 04:13:19 No, as this is called at script load time for Work
21 }
22
23 WorkletGlobalScope::~WorkletGlobalScope()
24 {
25 }
26
27 v8::Local<v8::Object> WorkletGlobalScope::wrap(v8::Isolate*, v8::Local<v8::Objec t> creationContext)
28 {
29 // WorkletGlobalScope must never be wrapped with wrap method. The global
30 // object of ECMAScript environment is used as the wrapper.
31 RELEASE_ASSERT_NOT_REACHED();
32 return v8::Local<v8::Object>();
33 }
34
35 v8::Local<v8::Object> WorkletGlobalScope::associateWithWrapper(v8::Isolate*, con st WrapperTypeInfo*, v8::Local<v8::Object> wrapper)
36 {
37 RELEASE_ASSERT_NOT_REACHED(); // same as wrap method
38 return v8::Local<v8::Object>();
39 }
40
41 void WorkletGlobalScope::disableEval(const String& errorMessage)
42 {
43 m_script->disableEval(errorMessage);
44 }
45
46 bool WorkletGlobalScope::isSecureContext(String& errorMessage, const SecureConte xtCheck privilegeContextCheck) const
47 {
48 // Until there are APIs that are available in worklets and that
49 // require a privileged context test that checks ancestors, just do
50 // a simple check here.
51 return securityOrigin()->isPotentiallyTrustworthy(errorMessage);
52 }
53
54 KURL WorkletGlobalScope::virtualCompleteURL(const String& url) const
55 {
56 // Always return a null URL when passed a null string.
57 // FIXME: Should we change the KURL constructor to have this behavior?
58 if (url.isNull())
59 return KURL();
60 // Always use UTF-8 in Worklets.
61 return KURL(m_url, url);
62 }
63
64 DEFINE_TRACE(WorkletGlobalScope)
65 {
66 visitor->trace(m_script);
67 ExecutionContext::trace(visitor);
68 SecurityContext::trace(visitor);
69 }
70
71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698