| 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/workers/WorkletGlobalScope.h" | 11 #include "core/workers/WorkletGlobalScope.h" |
| 12 #include "core/workers/WorkletPendingTasks.h" | 12 #include "core/workers/WorkletPendingTasks.h" |
| 13 #include "public/platform/WebURLRequest.h" | 13 #include "public/platform/WebURLRequest.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class ConsoleMessage; | 17 class ConsoleMessage; |
| 18 class LocalFrame; | 18 class LocalFrame; |
| 19 class ParentFrameTaskRunners; |
| 19 | 20 |
| 20 class CORE_EXPORT MainThreadWorkletGlobalScope | 21 class CORE_EXPORT MainThreadWorkletGlobalScope |
| 21 : public WorkletGlobalScope, | 22 : public WorkletGlobalScope, |
| 22 public ContextClient { | 23 public ContextClient { |
| 23 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorkletGlobalScope); | 24 USING_GARBAGE_COLLECTED_MIXIN(MainThreadWorkletGlobalScope); |
| 24 | 25 |
| 25 public: | 26 public: |
| 26 MainThreadWorkletGlobalScope(LocalFrame*, | 27 MainThreadWorkletGlobalScope(LocalFrame*, |
| 27 const KURL&, | 28 const KURL&, |
| 28 const String& user_agent, | 29 const String& user_agent, |
| 29 PassRefPtr<SecurityOrigin>, | 30 PassRefPtr<SecurityOrigin>, |
| 30 v8::Isolate*); | 31 v8::Isolate*); |
| 31 ~MainThreadWorkletGlobalScope() override; | 32 ~MainThreadWorkletGlobalScope() override; |
| 32 bool IsMainThreadWorkletGlobalScope() const final { return true; } | 33 bool IsMainThreadWorkletGlobalScope() const final { return true; } |
| 33 | 34 |
| 34 // WorkerOrWorkletGlobalScope | 35 // WorkerOrWorkletGlobalScope |
| 35 void ReportFeature(UseCounter::Feature) override; | 36 void ReportFeature(UseCounter::Feature) override; |
| 36 void ReportDeprecation(UseCounter::Feature) override; | 37 void ReportDeprecation(UseCounter::Feature) override; |
| 37 WorkerThread* GetThread() const final; | 38 WorkerThread* GetThread() const final; |
| 38 | 39 |
| 40 // Implementation of the "fetch and invoke a worklet script" algorithm: |
| 41 // https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script |
| 42 // When script evaluation is done or any exception happens, it's notified to |
| 43 // the given WorkletPendingTasks via the parent frame task runners. |
| 39 void FetchAndInvokeScript(const KURL& module_url_record, | 44 void FetchAndInvokeScript(const KURL& module_url_record, |
| 40 WebURLRequest::FetchCredentialsMode, | 45 WebURLRequest::FetchCredentialsMode, |
| 46 ParentFrameTaskRunners*, |
| 41 WorkletPendingTasks*); | 47 WorkletPendingTasks*); |
| 48 |
| 42 void Terminate(); | 49 void Terminate(); |
| 43 | 50 |
| 44 // ExecutionContext | 51 // ExecutionContext |
| 45 void AddConsoleMessage(ConsoleMessage*) final; | 52 void AddConsoleMessage(ConsoleMessage*) final; |
| 46 void ExceptionThrown(ErrorEvent*) final; | 53 void ExceptionThrown(ErrorEvent*) final; |
| 47 CoreProbeSink* GetProbeSink() final; | 54 CoreProbeSink* GetProbeSink() final; |
| 48 | 55 |
| 49 DECLARE_VIRTUAL_TRACE(); | 56 DECLARE_VIRTUAL_TRACE(); |
| 50 }; | 57 }; |
| 51 | 58 |
| 52 DEFINE_TYPE_CASTS(MainThreadWorkletGlobalScope, | 59 DEFINE_TYPE_CASTS(MainThreadWorkletGlobalScope, |
| 53 ExecutionContext, | 60 ExecutionContext, |
| 54 context, | 61 context, |
| 55 context->IsMainThreadWorkletGlobalScope(), | 62 context->IsMainThreadWorkletGlobalScope(), |
| 56 context.IsMainThreadWorkletGlobalScope()); | 63 context.IsMainThreadWorkletGlobalScope()); |
| 57 | 64 |
| 58 } // namespace blink | 65 } // namespace blink |
| 59 | 66 |
| 60 #endif // MainThreadWorkletGlobalScope_h | 67 #endif // MainThreadWorkletGlobalScope_h |
| OLD | NEW |