OLD | NEW |
| (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 #ifndef WorkletGlobalScope_h | |
6 #define WorkletGlobalScope_h | |
7 | |
8 #include "bindings/core/v8/ScriptWrappable.h" | |
9 #include "core/dom/ExecutionContext.h" | |
10 #include "core/dom/ExecutionContextTask.h" | |
11 #include "core/dom/SecurityContext.h" | |
12 #include "core/inspector/ConsoleMessage.h" | |
13 #include "core/workers/MainThreadWorkletGlobalScope.h" | |
14 #include "core/workers/WorkerOrWorkletGlobalScope.h" | |
15 #include "modules/ModulesExport.h" | |
16 #include "platform/heap/Handle.h" | |
17 | |
18 namespace blink { | |
19 | |
20 class EventQueue; | |
21 class LocalFrame; | |
22 class WorkerOrWorkletScriptController; | |
23 | |
24 class MODULES_EXPORT WorkletGlobalScope : public GarbageCollectedFinalized<Workl
etGlobalScope>, public SecurityContext, public MainThreadWorkletGlobalScope, pub
lic ScriptWrappable { | |
25 DEFINE_WRAPPERTYPEINFO(); | |
26 USING_GARBAGE_COLLECTED_MIXIN(WorkletGlobalScope); | |
27 public: | |
28 ~WorkletGlobalScope() override; | |
29 virtual void dispose(); | |
30 | |
31 bool isWorkletGlobalScope() const final { return true; } | |
32 | |
33 // WorkerOrWorkletGlobalScope | |
34 ScriptWrappable* getScriptWrappable() const final { return const_cast<Workle
tGlobalScope*>(this); } | |
35 WorkerOrWorkletScriptController* scriptController() final { return m_scriptC
ontroller.get(); } | |
36 | |
37 // ScriptWrappable | |
38 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte
xt) final; | |
39 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn
fo*, v8::Local<v8::Object> wrapper) final; | |
40 | |
41 // ExecutionContext | |
42 void disableEval(const String& errorMessage) final; | |
43 String userAgent() const final { return m_userAgent; } | |
44 SecurityContext& securityContext() final { return *this; } | |
45 EventQueue* getEventQueue() const final { ASSERT_NOT_REACHED(); return nullp
tr; } // WorkletGlobalScopes don't have an event queue. | |
46 bool isSecureContext(String& errorMessage, const SecureContextCheck = Standa
rdSecureContextCheck) const final; | |
47 | |
48 using SecurityContext::getSecurityOrigin; | |
49 using SecurityContext::contentSecurityPolicy; | |
50 | |
51 DOMTimerCoordinator* timers() final { ASSERT_NOT_REACHED(); return nullptr;
} // WorkletGlobalScopes don't have timers. | |
52 void postTask(const WebTraceLocation&, std::unique_ptr<ExecutionContextTask>
) override | |
53 { | |
54 // TODO(ikilpatrick): implement. | |
55 ASSERT_NOT_REACHED(); | |
56 } | |
57 | |
58 void reportBlockedScriptExecutionToInspector(const String& directiveText) fi
nal; | |
59 void addConsoleMessage(ConsoleMessage*) final; | |
60 void logExceptionToConsole(const String& errorMessage, PassOwnPtr<SourceLoca
tion>) final; | |
61 | |
62 DECLARE_VIRTUAL_TRACE(); | |
63 | |
64 protected: | |
65 // The url, userAgent and securityOrigin arguments are inherited from the | |
66 // parent ExecutionContext for Worklets. | |
67 WorkletGlobalScope(LocalFrame*, const KURL&, const String& userAgent, PassRe
fPtr<SecurityOrigin>, v8::Isolate*); | |
68 | |
69 private: | |
70 const KURL& virtualURL() const final { return m_url; } | |
71 KURL virtualCompleteURL(const String&) const final; | |
72 | |
73 EventTarget* errorEventTarget() final { return nullptr; } | |
74 void didUpdateSecurityOrigin() final { } | |
75 | |
76 KURL m_url; | |
77 String m_userAgent; | |
78 Member<WorkerOrWorkletScriptController> m_scriptController; | |
79 }; | |
80 | |
81 DEFINE_TYPE_CASTS(WorkletGlobalScope, ExecutionContext, context, context->isWork
letGlobalScope(), context.isWorkletGlobalScope()); | |
82 | |
83 } // namespace blink | |
84 | |
85 #endif // WorkletGlobalScope_h | |
OLD | NEW |