| 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 "platform/wtf/PtrUtil.h" | 11 #include "platform/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> worker_loader_proxy, | 16 ThreadableLoadingContext* loading_context, |
| 17 WorkerReportingProxy& worker_reporting_proxy) { | 17 WorkerReportingProxy& worker_reporting_proxy) { |
| 18 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("animation-worklet"), | 18 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("animation-worklet"), |
| 19 "AnimationWorkletThread::create"); | 19 "AnimationWorkletThread::create"); |
| 20 DCHECK(IsMainThread()); | 20 DCHECK(IsMainThread()); |
| 21 return WTF::WrapUnique(new AnimationWorkletThread( | 21 return WTF::WrapUnique( |
| 22 std::move(worker_loader_proxy), worker_reporting_proxy)); | 22 new AnimationWorkletThread(loading_context, worker_reporting_proxy)); |
| 23 } | 23 } |
| 24 | 24 |
| 25 AnimationWorkletThread::AnimationWorkletThread( | 25 AnimationWorkletThread::AnimationWorkletThread( |
| 26 PassRefPtr<WorkerLoaderProxy> worker_loader_proxy, | 26 ThreadableLoadingContext* loading_context, |
| 27 WorkerReportingProxy& worker_reporting_proxy) | 27 WorkerReportingProxy& worker_reporting_proxy) |
| 28 : AbstractAnimationWorkletThread(std::move(worker_loader_proxy), | 28 : AbstractAnimationWorkletThread(loading_context, worker_reporting_proxy) {} |
| 29 worker_reporting_proxy) {} | |
| 30 | 29 |
| 31 AnimationWorkletThread::~AnimationWorkletThread() {} | 30 AnimationWorkletThread::~AnimationWorkletThread() {} |
| 32 | 31 |
| 33 WorkerOrWorkletGlobalScope* AnimationWorkletThread::CreateWorkerGlobalScope( | 32 WorkerOrWorkletGlobalScope* AnimationWorkletThread::CreateWorkerGlobalScope( |
| 34 std::unique_ptr<WorkerThreadStartupData> startup_data) { | 33 std::unique_ptr<WorkerThreadStartupData> startup_data) { |
| 35 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("animation-worklet"), | 34 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("animation-worklet"), |
| 36 "AnimationWorkletThread::createWorkerGlobalScope"); | 35 "AnimationWorkletThread::createWorkerGlobalScope"); |
| 37 | 36 |
| 38 RefPtr<SecurityOrigin> security_origin = | 37 RefPtr<SecurityOrigin> security_origin = |
| 39 SecurityOrigin::Create(startup_data->script_url_); | 38 SecurityOrigin::Create(startup_data->script_url_); |
| 40 if (startup_data->starter_origin_privilege_data_) | 39 if (startup_data->starter_origin_privilege_data_) |
| 41 security_origin->TransferPrivilegesFrom( | 40 security_origin->TransferPrivilegesFrom( |
| 42 std::move(startup_data->starter_origin_privilege_data_)); | 41 std::move(startup_data->starter_origin_privilege_data_)); |
| 43 | 42 |
| 44 // TODO(ikilpatrick): The AnimationWorkletGlobalScope will need to store a | 43 // TODO(ikilpatrick): The AnimationWorkletGlobalScope will need to store a |
| 45 // WorkerClients object for using a CompositorWorkerProxyClient object. | 44 // WorkerClients object for using a CompositorWorkerProxyClient object. |
| 46 return AnimationWorkletGlobalScope::Create( | 45 return AnimationWorkletGlobalScope::Create( |
| 47 startup_data->script_url_, startup_data->user_agent_, | 46 startup_data->script_url_, startup_data->user_agent_, |
| 48 security_origin.Release(), this->GetIsolate(), this); | 47 security_origin.Release(), this->GetIsolate(), this); |
| 49 } | 48 } |
| 50 | 49 |
| 51 } // namespace blink | 50 } // namespace blink |
| OLD | NEW |