| 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 #include "modules/compositorworker/AnimationWorkletThread.h" | 5 #include "modules/compositorworker/AnimationWorkletThread.h" |
| 6 | 6 |
| 7 #include "core/workers/WorkerThreadStartupData.h" | 7 #include "core/workers/WorkerThreadStartupData.h" |
| 8 #include "modules/compositorworker/AnimationWorkletGlobalScope.h" | 8 #include "modules/compositorworker/AnimationWorkletGlobalScope.h" |
| 9 #include "platform/instrumentation/tracing/TraceEvent.h" | 9 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 10 #include "platform/weborigin/SecurityOrigin.h" | 10 #include "platform/weborigin/SecurityOrigin.h" |
| 11 #include "wtf/PtrUtil.h" | 11 #include "wtf/PtrUtil.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 std::unique_ptr<AnimationWorkletThread> AnimationWorkletThread::create( | 15 std::unique_ptr<AnimationWorkletThread> AnimationWorkletThread::create( |
| 16 PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, | 16 PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, |
| 17 WorkerReportingProxy& workerReportingProxy) { | 17 WorkerReportingProxy& workerReportingProxy, |
| 18 ParentFrameTaskRunners* parentFrameTaskRunners) { |
| 18 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("animation-worklet"), | 19 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("animation-worklet"), |
| 19 "AnimationWorkletThread::create"); | 20 "AnimationWorkletThread::create"); |
| 20 DCHECK(isMainThread()); | 21 DCHECK(isMainThread()); |
| 21 return WTF::wrapUnique(new AnimationWorkletThread( | 22 return WTF::wrapUnique( |
| 22 std::move(workerLoaderProxy), workerReportingProxy)); | 23 new AnimationWorkletThread(std::move(workerLoaderProxy), |
| 24 workerReportingProxy, parentFrameTaskRunners)); |
| 23 } | 25 } |
| 24 | 26 |
| 25 AnimationWorkletThread::AnimationWorkletThread( | 27 AnimationWorkletThread::AnimationWorkletThread( |
| 26 PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, | 28 PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, |
| 27 WorkerReportingProxy& workerReportingProxy) | 29 WorkerReportingProxy& workerReportingProxy, |
| 30 ParentFrameTaskRunners* parentFrameTaskRunners) |
| 28 : AbstractAnimationWorkletThread(std::move(workerLoaderProxy), | 31 : AbstractAnimationWorkletThread(std::move(workerLoaderProxy), |
| 29 workerReportingProxy) {} | 32 workerReportingProxy, |
| 33 parentFrameTaskRunners) {} |
| 30 | 34 |
| 31 AnimationWorkletThread::~AnimationWorkletThread() {} | 35 AnimationWorkletThread::~AnimationWorkletThread() {} |
| 32 | 36 |
| 33 WorkerOrWorkletGlobalScope* AnimationWorkletThread::createWorkerGlobalScope( | 37 WorkerOrWorkletGlobalScope* AnimationWorkletThread::createWorkerGlobalScope( |
| 34 std::unique_ptr<WorkerThreadStartupData> startupData) { | 38 std::unique_ptr<WorkerThreadStartupData> startupData) { |
| 35 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("animation-worklet"), | 39 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("animation-worklet"), |
| 36 "AnimationWorkletThread::createWorkerGlobalScope"); | 40 "AnimationWorkletThread::createWorkerGlobalScope"); |
| 37 | 41 |
| 38 RefPtr<SecurityOrigin> securityOrigin = | 42 RefPtr<SecurityOrigin> securityOrigin = |
| 39 SecurityOrigin::create(startupData->m_scriptURL); | 43 SecurityOrigin::create(startupData->m_scriptURL); |
| 40 if (startupData->m_starterOriginPrivilegeData) | 44 if (startupData->m_starterOriginPrivilegeData) |
| 41 securityOrigin->transferPrivilegesFrom( | 45 securityOrigin->transferPrivilegesFrom( |
| 42 std::move(startupData->m_starterOriginPrivilegeData)); | 46 std::move(startupData->m_starterOriginPrivilegeData)); |
| 43 | 47 |
| 44 // TODO(ikilpatrick): The AnimationWorkletGlobalScope will need to store a | 48 // TODO(ikilpatrick): The AnimationWorkletGlobalScope will need to store a |
| 45 // WorkerClients object for using a CompositorProxyClient object. | 49 // WorkerClients object for using a CompositorProxyClient object. |
| 46 return AnimationWorkletGlobalScope::create( | 50 return AnimationWorkletGlobalScope::create( |
| 47 startupData->m_scriptURL, startupData->m_userAgent, | 51 startupData->m_scriptURL, startupData->m_userAgent, |
| 48 securityOrigin.release(), this->isolate(), this); | 52 securityOrigin.release(), this->isolate(), this); |
| 49 } | 53 } |
| 50 | 54 |
| 51 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |