| 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" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // case. | 26 // case. |
| 27 class BackingThreadHolder { | 27 class BackingThreadHolder { |
| 28 public: | 28 public: |
| 29 static BackingThreadHolder& instance() | 29 static BackingThreadHolder& instance() |
| 30 { | 30 { |
| 31 DEFINE_THREAD_SAFE_STATIC_LOCAL(BackingThreadHolder, holder, new Backing
ThreadHolder); | 31 DEFINE_THREAD_SAFE_STATIC_LOCAL(BackingThreadHolder, holder, new Backing
ThreadHolder); |
| 32 return holder; | 32 return holder; |
| 33 } | 33 } |
| 34 | 34 |
| 35 WorkerBackingThread* thread() { return m_thread.get(); } | 35 WorkerBackingThread* thread() { return m_thread.get(); } |
| 36 void clear() { m_thread = nullptr; } |
| 36 void resetForTest() | 37 void resetForTest() |
| 37 { | 38 { |
| 38 ASSERT(!m_thread || (m_thread->workerScriptCount() == 0)); | 39 ASSERT(!m_thread || (m_thread->workerScriptCount() == 0)); |
| 39 m_thread = nullptr; | 40 m_thread = nullptr; |
| 40 m_thread = WorkerBackingThread::createForTest(Platform::current()->compo
sitorThread()); | 41 m_thread = WorkerBackingThread::createForTest(Platform::current()->compo
sitorThread()); |
| 41 } | 42 } |
| 42 | 43 |
| 43 private: | 44 private: |
| 44 BackingThreadHolder() : m_thread(WorkerBackingThread::create(Platform::curre
nt()->compositorThread())) {} | 45 BackingThreadHolder() : m_thread(WorkerBackingThread::create(Platform::curre
nt()->compositorThread())) {} |
| 45 | 46 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 70 { | 71 { |
| 71 return *BackingThreadHolder::instance().thread(); | 72 return *BackingThreadHolder::instance().thread(); |
| 72 } | 73 } |
| 73 | 74 |
| 74 WorkerGlobalScope*CompositorWorkerThread::createWorkerGlobalScope(PassOwnPtr<Wor
kerThreadStartupData> startupData) | 75 WorkerGlobalScope*CompositorWorkerThread::createWorkerGlobalScope(PassOwnPtr<Wor
kerThreadStartupData> startupData) |
| 75 { | 76 { |
| 76 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "CompositorWork
erThread::createWorkerGlobalScope"); | 77 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "CompositorWork
erThread::createWorkerGlobalScope"); |
| 77 return CompositorWorkerGlobalScope::create(this, std::move(startupData), m_t
imeOrigin); | 78 return CompositorWorkerGlobalScope::create(this, std::move(startupData), m_t
imeOrigin); |
| 78 } | 79 } |
| 79 | 80 |
| 81 void CompositorWorkerThread::ensureSharedBackingThread() |
| 82 { |
| 83 BackingThreadHolder::instance(); |
| 84 } |
| 85 |
| 86 void CompositorWorkerThread::clearSharedBackingThread() |
| 87 { |
| 88 BackingThreadHolder::instance().clear(); |
| 89 } |
| 90 |
| 80 void CompositorWorkerThread::resetSharedBackingThreadForTest() | 91 void CompositorWorkerThread::resetSharedBackingThreadForTest() |
| 81 { | 92 { |
| 82 BackingThreadHolder::instance().resetForTest(); | 93 BackingThreadHolder::instance().resetForTest(); |
| 83 } | 94 } |
| 84 | 95 |
| 85 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |