| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "platform/WebThreadSupportingGC.h" | 5 #include "platform/WebThreadSupportingGC.h" |
| 6 | 6 |
| 7 #include "platform/heap/SafePoint.h" | 7 #include "platform/heap/SafePoint.h" |
| 8 #include "public/platform/WebScheduler.h" | 8 #include "public/platform/WebScheduler.h" |
| 9 #include "wtf/PtrUtil.h" | 9 #include "wtf/PtrUtil.h" |
| 10 #include "wtf/Threading.h" | 10 #include "wtf/Threading.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 WebThread* thread, | 22 WebThread* thread, |
| 23 BlinkGC::ThreadHeapMode threadHeapMode) { | 23 BlinkGC::ThreadHeapMode threadHeapMode) { |
| 24 return wrapUnique(new WebThreadSupportingGC(nullptr, thread, threadHeapMode)); | 24 return wrapUnique(new WebThreadSupportingGC(nullptr, thread, threadHeapMode)); |
| 25 } | 25 } |
| 26 | 26 |
| 27 WebThreadSupportingGC::WebThreadSupportingGC( | 27 WebThreadSupportingGC::WebThreadSupportingGC( |
| 28 const char* name, | 28 const char* name, |
| 29 WebThread* thread, | 29 WebThread* thread, |
| 30 BlinkGC::ThreadHeapMode threadHeapMode) | 30 BlinkGC::ThreadHeapMode threadHeapMode) |
| 31 : m_thread(thread), m_threadHeapMode(threadHeapMode) { | 31 : m_thread(thread), m_threadHeapMode(threadHeapMode) { |
| 32 #if ENABLE(ASSERT) | 32 DCHECK(!name || !thread); |
| 33 ASSERT(!name || !thread); | 33 #if DCHECK_IS_ON() |
| 34 // We call this regardless of whether an existing thread is given or not, | 34 // We call this regardless of whether an existing thread is given or not, |
| 35 // as it means that blink is going to run with more than one thread. | 35 // as it means that blink is going to run with more than one thread. |
| 36 WTF::willCreateThread(); | 36 WTF::willCreateThread(); |
| 37 #endif | 37 #endif |
| 38 if (!m_thread) { | 38 if (!m_thread) { |
| 39 // If |thread| is not given, create a new one and own it. | 39 // If |thread| is not given, create a new one and own it. |
| 40 m_owningThread = wrapUnique(Platform::current()->createThread(name)); | 40 m_owningThread = wrapUnique(Platform::current()->createThread(name)); |
| 41 m_thread = m_owningThread.get(); | 41 m_thread = m_owningThread.get(); |
| 42 } | 42 } |
| 43 } | 43 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 64 | 64 |
| 65 // Shutdown the thread (via its scheduler) only when the thread is created | 65 // Shutdown the thread (via its scheduler) only when the thread is created |
| 66 // and is owned by this instance. | 66 // and is owned by this instance. |
| 67 if (m_owningThread) | 67 if (m_owningThread) |
| 68 m_owningThread->scheduler()->shutdown(); | 68 m_owningThread->scheduler()->shutdown(); |
| 69 | 69 |
| 70 ThreadState::detachCurrentThread(); | 70 ThreadState::detachCurrentThread(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 } // namespace blink | 73 } // namespace blink |
| OLD | NEW |