OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/compositorworker/CompositorWorkletThread.h" |
| 6 |
| 7 #include "core/workers/WorkerBackingThread.h" |
| 8 #include "modules/compositorworker/CompositorWorkletGlobalScope.h" |
| 9 #include "modules/worklet/WorkletThreadStartupData.h" |
| 10 #include "platform/weborigin/SecurityOrigin.h" |
| 11 #include "public/platform/Platform.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 namespace { |
| 16 |
| 17 // This is a singleton class holding the compositor worker thread in this |
| 18 // renderrer process. BackingThreadHolst::m_thread will never be cleared, |
| 19 // but Oilpan and V8 are detached from the thread when the last compositor |
| 20 // worker thread is gone. |
| 21 // See WorkerThread::terminateAndWaitForAllWorkers for the process shutdown |
| 22 // case. |
| 23 class BackingThreadHolder { |
| 24 public: |
| 25 static BackingThreadHolder& instance() |
| 26 { |
| 27 DEFINE_THREAD_SAFE_STATIC_LOCAL(BackingThreadHolder, holder, new Backing
ThreadHolder); |
| 28 return holder; |
| 29 } |
| 30 |
| 31 WorkerBackingThread* thread() { return m_thread.get(); } |
| 32 |
| 33 private: |
| 34 BackingThreadHolder() : m_thread(WorkerBackingThread::create(Platform::curre
nt()->compositorThread())) {} |
| 35 |
| 36 OwnPtr<WorkerBackingThread> m_thread; |
| 37 }; |
| 38 |
| 39 } // namespace |
| 40 |
| 41 PassOwnPtr<CompositorWorkletThread> CompositorWorkletThread::create(const KURL&
url, const String& userAgent, PassRefPtr<SecurityOrigin> securityOrigin) |
| 42 { |
| 43 CompositorWorkletThread* workletThread = new CompositorWorkletThread(); |
| 44 workletThread->initialize(WorkletThreadStartupData::create(url, userAgent, s
ecurityOrigin->isolatedCopy())); |
| 45 return adoptPtr(workletThread); |
| 46 } |
| 47 |
| 48 |
| 49 CompositorWorkletThread::CompositorWorkletThread() |
| 50 { |
| 51 } |
| 52 |
| 53 CompositorWorkletThread::~CompositorWorkletThread() |
| 54 { |
| 55 } |
| 56 |
| 57 WorkerBackingThread& CompositorWorkletThread::workerBackingThread() |
| 58 { |
| 59 return *BackingThreadHolder::instance().thread(); |
| 60 } |
| 61 |
| 62 WorkletGlobalScope* CompositorWorkletThread::createWorkletGlobalScope(const KURL
& url, const String& userAgent, PassRefPtr<SecurityOrigin> securityOrigin) |
| 63 { |
| 64 return CompositorWorkletGlobalScope::create(url, userAgent, securityOrigin,
workerBackingThread().isolate()); |
| 65 } |
| 66 |
| 67 } // namespace blink |
OLD | NEW |