Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: Source/modules/compositorworker/CompositorWorkerManager.cpp

Issue 1257723002: Simplify ownership of a ThreadState's interruptors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 ThreadState::current()->addInterruptor(new V8IsolateInterruptor(m_isolate));
93 ThreadState::current()->addInterruptor(m_interruptor.get());
94 ThreadState::current()->registerTraceDOMWrappers(m_isolate, V8GCController:: traceDOMWrappers); 93 ThreadState::current()->registerTraceDOMWrappers(m_isolate, V8GCController:: traceDOMWrappers);
95 } 94 }
96 95
97 void CompositorWorkerManager::shutdownBackingThread() 96 void CompositorWorkerManager::shutdownBackingThread()
98 { 97 {
99 MutexLocker lock(m_mutex); 98 MutexLocker lock(m_mutex);
100 ASSERT(m_thread->isCurrentThread()); 99 ASSERT(m_thread->isCurrentThread());
101 ASSERT(m_workerCount > 0); 100 ASSERT(m_workerCount > 0);
102 --m_workerCount; 101 --m_workerCount;
103 if (m_workerCount == 0) { 102 if (m_workerCount == 0) {
(...skipping 10 matching lines...) Expand all
114 ASSERT(m_isolate); 113 ASSERT(m_isolate);
115 // It is safe to use the existing isolate even if TerminateExecution() has b een 114 // It is safe to use the existing isolate even if TerminateExecution() has b een
116 // called on it, without calling CancelTerminateExecution(). 115 // called on it, without calling CancelTerminateExecution().
117 return m_isolate; 116 return m_isolate;
118 } 117 }
119 118
120 void CompositorWorkerManager::willDestroyIsolate() 119 void CompositorWorkerManager::willDestroyIsolate()
121 { 120 {
122 MutexLocker lock(m_mutex); 121 MutexLocker lock(m_mutex);
123 ASSERT(m_thread->isCurrentThread()); 122 ASSERT(m_thread->isCurrentThread());
124 if (m_workerCount == 1) { 123 if (m_workerCount == 1)
125 V8PerIsolateData::willBeDestroyed(m_isolate); 124 V8PerIsolateData::willBeDestroyed(m_isolate);
126 ThreadState::current()->removeInterruptor(m_interruptor.get());
127 }
128 } 125 }
129 126
130 void CompositorWorkerManager::destroyIsolate() 127 void CompositorWorkerManager::destroyIsolate()
131 { 128 {
132 MutexLocker lock(m_mutex); 129 MutexLocker lock(m_mutex);
133 if (!m_thread) { 130 if (!m_thread) {
134 ASSERT(m_workerCount == 0); 131 ASSERT(m_workerCount == 0);
135 V8PerIsolateData::destroy(m_isolate); 132 V8PerIsolateData::destroy(m_isolate);
136 m_isolate = nullptr; 133 m_isolate = nullptr;
137 } 134 }
138 } 135 }
139 136
140 void CompositorWorkerManager::terminateV8Execution() 137 void CompositorWorkerManager::terminateV8Execution()
141 { 138 {
142 MutexLocker lock(m_mutex); 139 MutexLocker lock(m_mutex);
143 ASSERT(isMainThread()); 140 ASSERT(isMainThread());
144 if (m_workerCount > 1) 141 if (m_workerCount > 1)
145 return; 142 return;
146 143
147 v8::V8::TerminateExecution(m_isolate); 144 v8::V8::TerminateExecution(m_isolate);
148 } 145 }
149 146
150 } // namespace blink 147 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698