| Index: third_party/WebKit/Source/modules/compositorworker/CompositorWorkletThread.cpp
|
| diff --git a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkletThread.cpp b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkletThread.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5847a3a8f5155e3bec4f09c70bc6e84693f3e06b
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkletThread.cpp
|
| @@ -0,0 +1,67 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "modules/compositorworker/CompositorWorkletThread.h"
|
| +
|
| +#include "core/workers/WorkerBackingThread.h"
|
| +#include "modules/compositorworker/CompositorWorkletGlobalScope.h"
|
| +#include "modules/worklet/WorkletThreadStartupData.h"
|
| +#include "platform/weborigin/SecurityOrigin.h"
|
| +#include "public/platform/Platform.h"
|
| +
|
| +namespace blink {
|
| +
|
| +namespace {
|
| +
|
| +// This is a singleton class holding the compositor worker thread in this
|
| +// renderrer process. BackingThreadHolst::m_thread will never be cleared,
|
| +// but Oilpan and V8 are detached from the thread when the last compositor
|
| +// worker thread is gone.
|
| +// See WorkerThread::terminateAndWaitForAllWorkers for the process shutdown
|
| +// case.
|
| +class BackingThreadHolder {
|
| +public:
|
| + static BackingThreadHolder& instance()
|
| + {
|
| + DEFINE_THREAD_SAFE_STATIC_LOCAL(BackingThreadHolder, holder, new BackingThreadHolder);
|
| + return holder;
|
| + }
|
| +
|
| + WorkerBackingThread* thread() { return m_thread.get(); }
|
| +
|
| +private:
|
| + BackingThreadHolder() : m_thread(WorkerBackingThread::create(Platform::current()->compositorThread())) {}
|
| +
|
| + OwnPtr<WorkerBackingThread> m_thread;
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +PassOwnPtr<CompositorWorkletThread> CompositorWorkletThread::create(const KURL& url, const String& userAgent, PassRefPtr<SecurityOrigin> securityOrigin)
|
| +{
|
| + CompositorWorkletThread* workletThread = new CompositorWorkletThread();
|
| + workletThread->initialize(WorkletThreadStartupData::create(url, userAgent, securityOrigin->isolatedCopy()));
|
| + return adoptPtr(workletThread);
|
| +}
|
| +
|
| +
|
| +CompositorWorkletThread::CompositorWorkletThread()
|
| +{
|
| +}
|
| +
|
| +CompositorWorkletThread::~CompositorWorkletThread()
|
| +{
|
| +}
|
| +
|
| +WorkerBackingThread& CompositorWorkletThread::workerBackingThread()
|
| +{
|
| + return *BackingThreadHolder::instance().thread();
|
| +}
|
| +
|
| +WorkletGlobalScope* CompositorWorkletThread::createWorkletGlobalScope(const KURL& url, const String& userAgent, PassRefPtr<SecurityOrigin> securityOrigin)
|
| +{
|
| + return CompositorWorkletGlobalScope::create(url, userAgent, securityOrigin, workerBackingThread().isolate());
|
| +}
|
| +
|
| +} // namespace blink
|
|
|