| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/compositorworker/CompositorWorkerManager.h" | 6 #include "modules/compositorworker/CompositorWorkerManager.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "bindings/core/v8/V8GCController.h" | 9 #include "bindings/core/v8/V8GCController.h" |
| 10 #include "bindings/core/v8/V8Initializer.h" | 10 #include "bindings/core/v8/V8Initializer.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 if (m_workerCount > 1) | 82 if (m_workerCount > 1) |
| 83 return; | 83 return; |
| 84 | 84 |
| 85 m_thread->initialize(); | 85 m_thread->initialize(); |
| 86 | 86 |
| 87 // Initialize the isolate at the same time. | 87 // Initialize the isolate at the same time. |
| 88 ASSERT(!m_isolate); | 88 ASSERT(!m_isolate); |
| 89 m_isolate = V8PerIsolateData::initialize(); | 89 m_isolate = V8PerIsolateData::initialize(); |
| 90 V8Initializer::initializeWorker(m_isolate); | 90 V8Initializer::initializeWorker(m_isolate); |
| 91 | 91 |
| 92 m_interruptor = adoptPtr(new V8IsolateInterruptor(m_isolate)); | 92 OwnPtr<V8IsolateInterruptor> interruptor = adoptPtr(new V8IsolateInterruptor
(m_isolate)); |
| 93 ThreadState::current()->addInterruptor(m_interruptor.get()); | 93 ThreadState::current()->addInterruptor(interruptor.release()); |
| 94 ThreadState::current()->registerTraceDOMWrappers(m_isolate, V8GCController::
traceDOMWrappers); | 94 ThreadState::current()->registerTraceDOMWrappers(m_isolate, V8GCController::
traceDOMWrappers); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void CompositorWorkerManager::shutdownBackingThread() | 97 void CompositorWorkerManager::shutdownBackingThread() |
| 98 { | 98 { |
| 99 MutexLocker lock(m_mutex); | 99 MutexLocker lock(m_mutex); |
| 100 ASSERT(m_thread->isCurrentThread()); | 100 ASSERT(m_thread->isCurrentThread()); |
| 101 ASSERT(m_workerCount > 0); | 101 ASSERT(m_workerCount > 0); |
| 102 --m_workerCount; | 102 --m_workerCount; |
| 103 if (m_workerCount == 0) { | 103 if (m_workerCount == 0) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 114 ASSERT(m_isolate); | 114 ASSERT(m_isolate); |
| 115 // It is safe to use the existing isolate even if TerminateExecution() has b
een | 115 // It is safe to use the existing isolate even if TerminateExecution() has b
een |
| 116 // called on it, without calling CancelTerminateExecution(). | 116 // called on it, without calling CancelTerminateExecution(). |
| 117 return m_isolate; | 117 return m_isolate; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void CompositorWorkerManager::willDestroyIsolate() | 120 void CompositorWorkerManager::willDestroyIsolate() |
| 121 { | 121 { |
| 122 MutexLocker lock(m_mutex); | 122 MutexLocker lock(m_mutex); |
| 123 ASSERT(m_thread->isCurrentThread()); | 123 ASSERT(m_thread->isCurrentThread()); |
| 124 if (m_workerCount == 1) { | 124 if (m_workerCount == 1) |
| 125 V8PerIsolateData::willBeDestroyed(m_isolate); | 125 V8PerIsolateData::willBeDestroyed(m_isolate); |
| 126 ThreadState::current()->removeInterruptor(m_interruptor.get()); | |
| 127 } | |
| 128 } | 126 } |
| 129 | 127 |
| 130 void CompositorWorkerManager::destroyIsolate() | 128 void CompositorWorkerManager::destroyIsolate() |
| 131 { | 129 { |
| 132 MutexLocker lock(m_mutex); | 130 MutexLocker lock(m_mutex); |
| 133 if (!m_thread) { | 131 if (!m_thread) { |
| 134 ASSERT(m_workerCount == 0); | 132 ASSERT(m_workerCount == 0); |
| 135 V8PerIsolateData::destroy(m_isolate); | 133 V8PerIsolateData::destroy(m_isolate); |
| 136 m_isolate = nullptr; | 134 m_isolate = nullptr; |
| 137 } | 135 } |
| 138 } | 136 } |
| 139 | 137 |
| 140 void CompositorWorkerManager::terminateV8Execution() | 138 void CompositorWorkerManager::terminateV8Execution() |
| 141 { | 139 { |
| 142 MutexLocker lock(m_mutex); | 140 MutexLocker lock(m_mutex); |
| 143 ASSERT(isMainThread()); | 141 ASSERT(isMainThread()); |
| 144 if (m_workerCount > 1) | 142 if (m_workerCount > 1) |
| 145 return; | 143 return; |
| 146 | 144 |
| 147 v8::V8::TerminateExecution(m_isolate); | 145 v8::V8::TerminateExecution(m_isolate); |
| 148 } | 146 } |
| 149 | 147 |
| 150 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |