| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/CompositorWorkerThread.h" | 5 #include "modules/compositorworker/CompositorWorkerThread.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8GCController.h" | 7 #include "bindings/core/v8/V8GCController.h" |
| 8 #include "bindings/core/v8/V8Initializer.h" | 8 #include "bindings/core/v8/V8Initializer.h" |
| 9 #include "core/workers/InProcessWorkerObjectProxy.h" | 9 #include "core/workers/InProcessWorkerObjectProxy.h" |
| 10 #include "core/workers/WorkerBackingThread.h" | 10 #include "core/workers/WorkerBackingThread.h" |
| 11 #include "core/workers/WorkerThreadStartupData.h" | 11 #include "core/workers/WorkerThreadStartupData.h" |
| 12 #include "modules/compositorworker/CompositorWorkerGlobalScope.h" | 12 #include "modules/compositorworker/CompositorWorkerGlobalScope.h" |
| 13 #include "platform/ThreadSafeFunctional.h" | 13 #include "platform/ThreadSafeFunctional.h" |
| 14 #include "platform/TraceEvent.h" | 14 #include "platform/TraceEvent.h" |
| 15 #include "public/platform/Platform.h" | 15 #include "public/platform/Platform.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // This is a singleton class holding the compositor worker thread in this |
| 22 // renderrer process. BackingThreadHolst::m_thread will never be cleared, |
| 23 // but Oilpan and V8 are detached from the thread when the last compositor |
| 24 // worker thread is gone. |
| 25 // See WorkerThread::terminateAndWaitForAllWorkers for the process shutdown |
| 26 // case. |
| 21 class BackingThreadHolder { | 27 class BackingThreadHolder { |
| 22 public: | 28 public: |
| 23 static BackingThreadHolder& instance() | 29 static BackingThreadHolder& instance() |
| 24 { | 30 { |
| 25 DEFINE_THREAD_SAFE_STATIC_LOCAL(BackingThreadHolder, holder, new Backing
ThreadHolder); | 31 DEFINE_THREAD_SAFE_STATIC_LOCAL(BackingThreadHolder, holder, new Backing
ThreadHolder); |
| 26 return holder; | 32 return holder; |
| 27 } | 33 } |
| 28 | 34 |
| 29 WorkerBackingThread* thread() { return m_thread.get(); } | 35 WorkerBackingThread* thread() { return m_thread.get(); } |
| 30 void clear() { m_thread = nullptr; } | |
| 31 void resetForTest() | 36 void resetForTest() |
| 32 { | 37 { |
| 33 ASSERT(!m_thread || (m_thread->workerScriptCount() == 0)); | 38 ASSERT(!m_thread || (m_thread->workerScriptCount() == 0)); |
| 39 m_thread = nullptr; |
| 34 m_thread = WorkerBackingThread::createForTest(Platform::current()->compo
sitorThread()); | 40 m_thread = WorkerBackingThread::createForTest(Platform::current()->compo
sitorThread()); |
| 35 } | 41 } |
| 36 | 42 |
| 37 private: | 43 private: |
| 38 BackingThreadHolder() : m_thread(WorkerBackingThread::create(Platform::curre
nt()->compositorThread())) {} | 44 BackingThreadHolder() : m_thread(WorkerBackingThread::create(Platform::curre
nt()->compositorThread())) {} |
| 39 | 45 |
| 40 OwnPtr<WorkerBackingThread> m_thread; | 46 OwnPtr<WorkerBackingThread> m_thread; |
| 41 }; | 47 }; |
| 42 | 48 |
| 43 } // namespace | 49 } // namespace |
| (...skipping 20 matching lines...) Expand all Loading... |
| 64 { | 70 { |
| 65 return *BackingThreadHolder::instance().thread(); | 71 return *BackingThreadHolder::instance().thread(); |
| 66 } | 72 } |
| 67 | 73 |
| 68 WorkerGlobalScope*CompositorWorkerThread::createWorkerGlobalScope(PassOwnPtr<Wor
kerThreadStartupData> startupData) | 74 WorkerGlobalScope*CompositorWorkerThread::createWorkerGlobalScope(PassOwnPtr<Wor
kerThreadStartupData> startupData) |
| 69 { | 75 { |
| 70 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "CompositorWork
erThread::createWorkerGlobalScope"); | 76 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "CompositorWork
erThread::createWorkerGlobalScope"); |
| 71 return CompositorWorkerGlobalScope::create(this, std::move(startupData), m_t
imeOrigin); | 77 return CompositorWorkerGlobalScope::create(this, std::move(startupData), m_t
imeOrigin); |
| 72 } | 78 } |
| 73 | 79 |
| 74 void CompositorWorkerThread::clearSharedBackingThread() | |
| 75 { | |
| 76 BackingThreadHolder::instance().clear(); | |
| 77 } | |
| 78 | |
| 79 void CompositorWorkerThread::resetSharedBackingThreadForTest() | 80 void CompositorWorkerThread::resetSharedBackingThreadForTest() |
| 80 { | 81 { |
| 81 BackingThreadHolder::instance().resetForTest(); | 82 BackingThreadHolder::instance().resetForTest(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 } // namespace blink | 85 } // namespace blink |
| OLD | NEW |