OLD | NEW |
---|---|
(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 #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/inspector/ScriptCallStack.h" | |
14 #include "platform/heap/Handle.h" | |
15 | |
16 namespace blink { | |
17 | |
18 class EventQueue; | |
19 class IsolatedScriptController; | |
20 | |
21 class WorkletGlobalScope : public RefCountedWillBeNoBase<WorkletGlobalScope>, pu blic SecurityContext, public ExecutionContext, public ScriptWrappable { | |
haraken
2016/01/05 06:08:06
Doesn't WorkletGlobalScope need to be an EventTarg
ikilpatrick
2016/01/07 22:47:35
Done. Yeah it's not an event target at the moment.
| |
22 DEFINE_WRAPPERTYPEINFO(); | |
23 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WorkletGlobalScope); | |
24 public: | |
25 #if !ENABLE(OILPAN) | |
26 using RefCounted<WorkletGlobalScope>::ref; | |
27 using RefCounted<WorkletGlobalScope>::deref; | |
haraken
2016/01/05 06:08:06
This doesn't make sense if the WorkletGlobalScope
ikilpatrick
2016/01/07 22:47:35
Isn't this needed to disambiguate between RefCount
haraken
2016/01/08 04:59:07
Then it would be better to have:
#if !ENABLE(OILP
ikilpatrick
2016/01/11 04:13:19
That is already defined in the private section bel
| |
28 #endif | |
29 | |
30 // The url and userAgent arguments are inherited from the parent | |
31 // ExecutionContext for Worklets. | |
32 static PassRefPtrWillBeRawPtr<WorkletGlobalScope> create(const KURL&, const String& userAgent, v8::Isolate*); | |
33 ~WorkletGlobalScope() override; | |
34 | |
35 bool isWorkletGlobalScope() const final { return true; } | |
36 | |
37 IsolatedScriptController* script(); | |
38 v8::Isolate* isolate() const { return m_isolate; } | |
39 | |
40 // ScriptWrappable | |
41 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) final; | |
42 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn fo*, v8::Local<v8::Object> wrapper) final; | |
43 | |
44 // ExecutionContext | |
45 void disableEval(const String& errorMessage) final; | |
46 String userAgent() const final { return m_userAgent; } | |
47 SecurityContext& securityContext() final { return *this; } | |
48 EventQueue* eventQueue() const final { ASSERT_NOT_REACHED(); return nullptr; } // WorkletGlobalScopes don't have an event queue. | |
49 bool isSecureContext(String& errorMessage, const SecureContextCheck = Standa rdSecureContextCheck) const final; | |
50 | |
51 using SecurityContext::securityOrigin; | |
52 using SecurityContext::contentSecurityPolicy; | |
53 | |
54 DOMTimerCoordinator* timers() final { ASSERT_NOT_REACHED(); return nullptr; } // WorkletGlobalScopes don't have timers. | |
55 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>) ove rride { } | |
56 | |
57 // TODO(ikilpatrick): implement when we implement devtools support. | |
58 void reportBlockedScriptExecutionToInspector(const String& directiveText) fi nal { } | |
59 void addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) final { } | |
60 void logExceptionToConsole(const String& errorMessage, int scriptId, const S tring& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBeRawPtr<Scrip tCallStack>) final { } | |
61 | |
62 DECLARE_VIRTUAL_TRACE(); | |
63 | |
64 private: | |
65 #if !ENABLE(OILPAN) | |
66 void refExecutionContext() final { ref(); } | |
67 void derefExecutionContext() final { deref(); } | |
68 #endif | |
69 | |
70 WorkletGlobalScope(const KURL&, const String& userAgent, v8::Isolate*); | |
71 | |
72 const KURL& virtualURL() const final { return m_url; } | |
73 KURL virtualCompleteURL(const String&) const final; | |
74 | |
75 EventTarget* errorEventTarget() final { return nullptr; } | |
76 void didUpdateSecurityOrigin() final { } | |
77 | |
78 KURL m_url; | |
79 String m_userAgent; | |
80 v8::Isolate* m_isolate; | |
haraken
2016/01/05 06:08:06
Remove this. You can use m_scriptState->isolate().
ikilpatrick
2016/01/07 22:47:35
Done.
| |
81 OwnPtrWillBeMember<IsolatedScriptController> m_script; | |
82 }; | |
83 | |
84 DEFINE_TYPE_CASTS(WorkletGlobalScope, ExecutionContext, context, context->isWork letGlobalScope(), context.isWorkletGlobalScope()); | |
85 | |
86 } // namespace blink | |
87 | |
88 #endif // WorkletGlobalScope_h | |
OLD | NEW |