| 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 MainThreadWorkletGlobalScope_h | 5 #ifndef MainThreadWorkletGlobalScope_h |
| 6 #define MainThreadWorkletGlobalScope_h | 6 #define MainThreadWorkletGlobalScope_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/dom/ContextLifecycleObserver.h" | 9 #include "core/dom/ContextLifecycleObserver.h" |
| 10 #include "core/dom/ExecutionContext.h" | 10 #include "core/dom/ExecutionContext.h" |
| 11 #include "core/loader/WorkletScriptLoader.h" | 11 #include "core/loader/WorkletScriptLoader.h" |
| 12 #include "core/workers/WorkletGlobalScope.h" | 12 #include "core/workers/WorkletGlobalScope.h" |
| 13 #include "core/workers/WorkletGlobalScopeProxy.h" | |
| 14 #include "core/workers/WorkletPendingTasks.h" | 13 #include "core/workers/WorkletPendingTasks.h" |
| 15 | 14 |
| 16 namespace blink { | 15 namespace blink { |
| 17 | 16 |
| 18 class ConsoleMessage; | 17 class ConsoleMessage; |
| 19 class LocalFrame; | 18 class LocalFrame; |
| 20 class ScriptSourceCode; | 19 class ScriptSourceCode; |
| 21 | 20 |
| 22 class CORE_EXPORT MainThreadWorkletGlobalScope | 21 class CORE_EXPORT MainThreadWorkletGlobalScope |
| 23 : public WorkletGlobalScope, | 22 : public WorkletGlobalScope, |
| 24 public WorkletGlobalScopeProxy, | |
| 25 public WorkletScriptLoader::Client, | 23 public WorkletScriptLoader::Client, |
| 26 public ContextClient { | 24 public ContextClient { |
| 27 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorkletGlobalScope); | 25 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorkletGlobalScope); |
| 28 | 26 |
| 29 public: | 27 public: |
| 30 MainThreadWorkletGlobalScope(LocalFrame*, | 28 MainThreadWorkletGlobalScope(LocalFrame*, |
| 31 const KURL&, | 29 const KURL&, |
| 32 const String& user_agent, | 30 const String& user_agent, |
| 33 PassRefPtr<SecurityOrigin>, | 31 PassRefPtr<SecurityOrigin>, |
| 34 v8::Isolate*); | 32 v8::Isolate*); |
| 35 ~MainThreadWorkletGlobalScope() override; | 33 ~MainThreadWorkletGlobalScope() override; |
| 36 bool IsMainThreadWorkletGlobalScope() const final { return true; } | 34 bool IsMainThreadWorkletGlobalScope() const final { return true; } |
| 37 | 35 |
| 38 // WorkerOrWorkletGlobalScope | 36 // WorkerOrWorkletGlobalScope |
| 39 void CountFeature(UseCounter::Feature) final; | 37 void CountFeature(UseCounter::Feature) final; |
| 40 void CountDeprecation(UseCounter::Feature) final; | 38 void CountDeprecation(UseCounter::Feature) final; |
| 41 WorkerThread* GetThread() const final; | 39 WorkerThread* GetThread() const final; |
| 42 | 40 |
| 43 // WorkletGlobalScopeProxy | |
| 44 void FetchAndInvokeScript(const KURL& module_url_record, | 41 void FetchAndInvokeScript(const KURL& module_url_record, |
| 45 WorkletPendingTasks*) final; | 42 WorkletPendingTasks*); |
| 46 void EvaluateScript(const ScriptSourceCode&) final; | 43 void Terminate(); |
| 47 void TerminateWorkletGlobalScope() final; | |
| 48 | 44 |
| 49 // WorkletScriptLoader::Client | 45 // WorkletScriptLoader::Client |
| 50 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*, | 46 void NotifyWorkletScriptLoadingFinished(WorkletScriptLoader*, |
| 51 const ScriptSourceCode&) final; | 47 const ScriptSourceCode&) final; |
| 52 | 48 |
| 53 // ExecutionContext | 49 // ExecutionContext |
| 54 void AddConsoleMessage(ConsoleMessage*) final; | 50 void AddConsoleMessage(ConsoleMessage*) final; |
| 55 void ExceptionThrown(ErrorEvent*) final; | 51 void ExceptionThrown(ErrorEvent*) final; |
| 56 CoreProbeSink* GetProbeSink() final; | 52 CoreProbeSink* GetProbeSink() final; |
| 57 | 53 |
| 58 DECLARE_VIRTUAL_TRACE(); | 54 DECLARE_VIRTUAL_TRACE(); |
| 59 | 55 |
| 60 private: | 56 private: |
| 61 HeapHashMap<Member<WorkletScriptLoader>, Member<WorkletPendingTasks>> | 57 HeapHashMap<Member<WorkletScriptLoader>, Member<WorkletPendingTasks>> |
| 62 loader_map_; | 58 loader_map_; |
| 63 }; | 59 }; |
| 64 | 60 |
| 65 DEFINE_TYPE_CASTS(MainThreadWorkletGlobalScope, | 61 DEFINE_TYPE_CASTS(MainThreadWorkletGlobalScope, |
| 66 ExecutionContext, | 62 ExecutionContext, |
| 67 context, | 63 context, |
| 68 context->IsMainThreadWorkletGlobalScope(), | 64 context->IsMainThreadWorkletGlobalScope(), |
| 69 context.IsMainThreadWorkletGlobalScope()); | 65 context.IsMainThreadWorkletGlobalScope()); |
| 70 | 66 |
| 71 } // namespace blink | 67 } // namespace blink |
| 72 | 68 |
| 73 #endif // MainThreadWorkletGlobalScope_h | 69 #endif // MainThreadWorkletGlobalScope_h |
| OLD | NEW |