| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WorkletGlobalScope_h | 5 #ifndef WorkletGlobalScope_h |
| 6 #define WorkletGlobalScope_h | 6 #define WorkletGlobalScope_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptCallStack.h" | 8 #include "bindings/core/v8/ScriptCallStack.h" |
| 9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| 11 #include "core/dom/ExecutionContextTask.h" | 11 #include "core/dom/ExecutionContextTask.h" |
| 12 #include "core/dom/SecurityContext.h" | 12 #include "core/dom/SecurityContext.h" |
| 13 #include "core/inspector/ConsoleMessage.h" | 13 #include "core/inspector/ConsoleMessage.h" |
| 14 #include "core/workers/MainThreadWorkletGlobalScope.h" | 14 #include "core/workers/MainThreadWorkletGlobalScope.h" |
| 15 #include "core/workers/WorkerOrWorkletGlobalScope.h" | 15 #include "core/workers/WorkerOrWorkletGlobalScope.h" |
| 16 #include "platform/heap/Handle.h" | 16 #include "platform/heap/Handle.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 class EventQueue; | 20 class EventQueue; |
| 21 class LocalFrame; | 21 class LocalFrame; |
| 22 class WorkerOrWorkletScriptController; | 22 class WorkerOrWorkletScriptController; |
| 23 class WorkletConsole; | 23 class WorkletConsole; |
| 24 | 24 |
| 25 class WorkletGlobalScope : public RefCountedWillBeGarbageCollectedFinalized<Work
letGlobalScope>, public SecurityContext, public MainThreadWorkletGlobalScope, pu
blic ScriptWrappable { | 25 class WorkletGlobalScope : public GarbageCollectedFinalized<WorkletGlobalScope>,
public SecurityContext, public MainThreadWorkletGlobalScope, public ScriptWrapp
able { |
| 26 DEFINE_WRAPPERTYPEINFO(); | 26 DEFINE_WRAPPERTYPEINFO(); |
| 27 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WorkletGlobalScope); | 27 USING_GARBAGE_COLLECTED_MIXIN(WorkletGlobalScope); |
| 28 public: | 28 public: |
| 29 #if !ENABLE(OILPAN) | 29 #if !ENABLE(OILPAN) |
| 30 using RefCounted<WorkletGlobalScope>::ref; | 30 using RefCounted<WorkletGlobalScope>::ref; |
| 31 using RefCounted<WorkletGlobalScope>::deref; | 31 using RefCounted<WorkletGlobalScope>::deref; |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 ~WorkletGlobalScope() override; | 34 ~WorkletGlobalScope() override; |
| 35 | 35 |
| 36 bool isWorkletGlobalScope() const final { return true; } | 36 bool isWorkletGlobalScope() const final { return true; } |
| 37 | 37 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 57 using SecurityContext::contentSecurityPolicy; | 57 using SecurityContext::contentSecurityPolicy; |
| 58 | 58 |
| 59 DOMTimerCoordinator* timers() final { ASSERT_NOT_REACHED(); return nullptr;
} // WorkletGlobalScopes don't have timers. | 59 DOMTimerCoordinator* timers() final { ASSERT_NOT_REACHED(); return nullptr;
} // WorkletGlobalScopes don't have timers. |
| 60 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>) ove
rride | 60 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>) ove
rride |
| 61 { | 61 { |
| 62 // TODO(ikilpatrick): implement. | 62 // TODO(ikilpatrick): implement. |
| 63 ASSERT_NOT_REACHED(); | 63 ASSERT_NOT_REACHED(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void reportBlockedScriptExecutionToInspector(const String& directiveText) fi
nal; | 66 void reportBlockedScriptExecutionToInspector(const String& directiveText) fi
nal; |
| 67 void addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) final; | 67 void addConsoleMessage(RawPtr<ConsoleMessage>) final; |
| 68 void logExceptionToConsole(const String& errorMessage, int scriptId, const S
tring& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>)
final; | 68 void logExceptionToConsole(const String& errorMessage, int scriptId, const S
tring& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>)
final; |
| 69 | 69 |
| 70 DECLARE_VIRTUAL_TRACE(); | 70 DECLARE_VIRTUAL_TRACE(); |
| 71 | 71 |
| 72 protected: | 72 protected: |
| 73 // The url, userAgent and securityOrigin arguments are inherited from the | 73 // The url, userAgent and securityOrigin arguments are inherited from the |
| 74 // parent ExecutionContext for Worklets. | 74 // parent ExecutionContext for Worklets. |
| 75 WorkletGlobalScope(LocalFrame*, const KURL&, const String& userAgent, PassRe
fPtr<SecurityOrigin>, v8::Isolate*); | 75 WorkletGlobalScope(LocalFrame*, const KURL&, const String& userAgent, PassRe
fPtr<SecurityOrigin>, v8::Isolate*); |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 #if !ENABLE(OILPAN) | 78 #if !ENABLE(OILPAN) |
| 79 void refExecutionContext() final { ref(); } | 79 void refExecutionContext() final { ref(); } |
| 80 void derefExecutionContext() final { deref(); } | 80 void derefExecutionContext() final { deref(); } |
| 81 #endif | 81 #endif |
| 82 | 82 |
| 83 const KURL& virtualURL() const final { return m_url; } | 83 const KURL& virtualURL() const final { return m_url; } |
| 84 KURL virtualCompleteURL(const String&) const final; | 84 KURL virtualCompleteURL(const String&) const final; |
| 85 | 85 |
| 86 EventTarget* errorEventTarget() final { return nullptr; } | 86 EventTarget* errorEventTarget() final { return nullptr; } |
| 87 void didUpdateSecurityOrigin() final { } | 87 void didUpdateSecurityOrigin() final { } |
| 88 | 88 |
| 89 mutable PersistentWillBeMember<WorkletConsole> m_console; | 89 mutable Member<WorkletConsole> m_console; |
| 90 | 90 |
| 91 KURL m_url; | 91 KURL m_url; |
| 92 String m_userAgent; | 92 String m_userAgent; |
| 93 OwnPtrWillBeMember<WorkerOrWorkletScriptController> m_scriptController; | 93 Member<WorkerOrWorkletScriptController> m_scriptController; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 DEFINE_TYPE_CASTS(WorkletGlobalScope, ExecutionContext, context, context->isWork
letGlobalScope(), context.isWorkletGlobalScope()); | 96 DEFINE_TYPE_CASTS(WorkletGlobalScope, ExecutionContext, context, context->isWork
letGlobalScope(), context.isWorkletGlobalScope()); |
| 97 | 97 |
| 98 } // namespace blink | 98 } // namespace blink |
| 99 | 99 |
| 100 #endif // WorkletGlobalScope_h | 100 #endif // WorkletGlobalScope_h |
| OLD | NEW |