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

Side by Side Diff: third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.h

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 #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 WorkerOrWorkletScriptController;
20
21 class WorkletGlobalScope : public RefCountedWillBeGarbageCollectedFinalized<Work letGlobalScope>, public SecurityContext, public ExecutionContext, public ScriptW rappable {
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;
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 WorkerOrWorkletScriptController* script() { return m_script.get(); }
38
39 // ScriptWrappable
40 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte xt) final;
41 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn fo*, v8::Local<v8::Object> wrapper) final;
42
43 // ExecutionContext
44 void disableEval(const String& errorMessage) final;
45 String userAgent() const final { return m_userAgent; }
46 SecurityContext& securityContext() final { return *this; }
47 EventQueue* eventQueue() const final { ASSERT_NOT_REACHED(); return nullptr; } // WorkletGlobalScopes don't have an event queue.
48 bool isSecureContext(String& errorMessage, const SecureContextCheck = Standa rdSecureContextCheck) const final;
49
50 using SecurityContext::securityOrigin;
51 using SecurityContext::contentSecurityPolicy;
52
53 DOMTimerCoordinator* timers() final { ASSERT_NOT_REACHED(); return nullptr; } // WorkletGlobalScopes don't have timers.
54 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>) ove rride
55 {
56 // TODO(ikilpatrick): implement.
57 ASSERT_NOT_REACHED();
58 }
59
60 // TODO(ikilpatrick): implement when we implement devtools support.
61 void reportBlockedScriptExecutionToInspector(const String& directiveText) fi nal { }
62 void addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) final { }
63 void logExceptionToConsole(const String& errorMessage, int scriptId, const S tring& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBeRawPtr<Scrip tCallStack>) final { }
64
65 DECLARE_VIRTUAL_TRACE();
66
67 private:
68 #if !ENABLE(OILPAN)
69 void refExecutionContext() final { ref(); }
70 void derefExecutionContext() final { deref(); }
71 #endif
72
73 WorkletGlobalScope(const KURL&, const String& userAgent, v8::Isolate*);
74
75 const KURL& virtualURL() const final { return m_url; }
76 KURL virtualCompleteURL(const String&) const final;
77
78 EventTarget* errorEventTarget() final { return nullptr; }
79 void didUpdateSecurityOrigin() final { }
80
81 KURL m_url;
82 String m_userAgent;
83 OwnPtrWillBeMember<WorkerOrWorkletScriptController> m_script;
84 };
85
86 DEFINE_TYPE_CASTS(WorkletGlobalScope, ExecutionContext, context, context->isWork letGlobalScope(), context.isWorkletGlobalScope());
87
88 } // namespace blink
89
90 #endif // WorkletGlobalScope_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698