Chromium Code Reviews| Index: third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.h |
| diff --git a/third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.h b/third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ce9dd3fe7239b2c51cb9922bd3e1fad869c26158 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.h |
| @@ -0,0 +1,88 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef WorkletGlobalScope_h |
| +#define WorkletGlobalScope_h |
| + |
| +#include "bindings/core/v8/ScriptWrappable.h" |
| +#include "core/dom/ExecutionContext.h" |
| +#include "core/dom/ExecutionContextTask.h" |
| +#include "core/dom/SecurityContext.h" |
| +#include "core/inspector/ConsoleMessage.h" |
| +#include "core/inspector/ScriptCallStack.h" |
| +#include "platform/heap/Handle.h" |
| + |
| +namespace blink { |
| + |
| +class EventQueue; |
| +class IsolatedScriptController; |
| + |
| +class WorkletGlobalScope : public RefCountedWillBeNoBase<WorkletGlobalScope>, public 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.
|
| + DEFINE_WRAPPERTYPEINFO(); |
| + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WorkletGlobalScope); |
| +public: |
| +#if !ENABLE(OILPAN) |
| + using RefCounted<WorkletGlobalScope>::ref; |
| + 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
|
| +#endif |
| + |
| + // The url and userAgent arguments are inherited from the parent |
| + // ExecutionContext for Worklets. |
| + static PassRefPtrWillBeRawPtr<WorkletGlobalScope> create(const KURL&, const String& userAgent, v8::Isolate*); |
| + ~WorkletGlobalScope() override; |
| + |
| + bool isWorkletGlobalScope() const final { return true; } |
| + |
| + IsolatedScriptController* script(); |
| + v8::Isolate* isolate() const { return m_isolate; } |
| + |
| + // ScriptWrappable |
| + v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationContext) final; |
| + v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeInfo*, v8::Local<v8::Object> wrapper) final; |
| + |
| + // ExecutionContext |
| + void disableEval(const String& errorMessage) final; |
| + String userAgent() const final { return m_userAgent; } |
| + SecurityContext& securityContext() final { return *this; } |
| + EventQueue* eventQueue() const final { ASSERT_NOT_REACHED(); return nullptr; } // WorkletGlobalScopes don't have an event queue. |
| + bool isSecureContext(String& errorMessage, const SecureContextCheck = StandardSecureContextCheck) const final; |
| + |
| + using SecurityContext::securityOrigin; |
| + using SecurityContext::contentSecurityPolicy; |
| + |
| + DOMTimerCoordinator* timers() final { ASSERT_NOT_REACHED(); return nullptr; } // WorkletGlobalScopes don't have timers. |
| + void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>) override { } |
| + |
| + // TODO(ikilpatrick): implement when we implement devtools support. |
| + void reportBlockedScriptExecutionToInspector(const String& directiveText) final { } |
| + void addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) final { } |
| + void logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBeRawPtr<ScriptCallStack>) final { } |
| + |
| + DECLARE_VIRTUAL_TRACE(); |
| + |
| +private: |
| +#if !ENABLE(OILPAN) |
| + void refExecutionContext() final { ref(); } |
| + void derefExecutionContext() final { deref(); } |
| +#endif |
| + |
| + WorkletGlobalScope(const KURL&, const String& userAgent, v8::Isolate*); |
| + |
| + const KURL& virtualURL() const final { return m_url; } |
| + KURL virtualCompleteURL(const String&) const final; |
| + |
| + EventTarget* errorEventTarget() final { return nullptr; } |
| + void didUpdateSecurityOrigin() final { } |
| + |
| + KURL m_url; |
| + String m_userAgent; |
| + 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.
|
| + OwnPtrWillBeMember<IsolatedScriptController> m_script; |
| +}; |
| + |
| +DEFINE_TYPE_CASTS(WorkletGlobalScope, ExecutionContext, context, context->isWorkletGlobalScope(), context.isWorkletGlobalScope()); |
| + |
| +} // namespace blink |
| + |
| +#endif // WorkletGlobalScope_h |