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

Unified Diff: Source/modules/compositorworker/CompositorWorkerManager.cpp

Issue 1319363002: Makes WebThreadSupportingGC constructible for an existing thread (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/compositorworker/CompositorWorkerManager.cpp
diff --git a/Source/modules/compositorworker/CompositorWorkerManager.cpp b/Source/modules/compositorworker/CompositorWorkerManager.cpp
index 62dc23b4c02a2ce82f05a4a82fc2cac2460c447f..21cce23086c7d616b3fed257bbf35ab78eb7e5e9 100644
--- a/Source/modules/compositorworker/CompositorWorkerManager.cpp
+++ b/Source/modules/compositorworker/CompositorWorkerManager.cpp
@@ -20,13 +20,13 @@ namespace {
static CompositorWorkerManager* s_instance = nullptr;
-static Mutex& singletonMutex()
+Mutex& singletonMutex()
{
AtomicallyInitializedStaticReference(Mutex, mutex, new Mutex);
return mutex;
}
-static void destroyThread(WebThreadSupportingGC* thread)
+void destroyThread(WebThread* thread)
{
delete thread;
}
@@ -69,7 +69,11 @@ WebThreadSupportingGC& CompositorWorkerManager::compositorWorkerThread()
if (!m_thread) {
ASSERT(isMainThread());
ASSERT(!m_workerCount);
- m_thread = WebThreadSupportingGC::create("CompositorWorker Thread");
+ // TODO(sadrul): Instead of creating a new thread, retrieve the thread from
+ // Platform using a more specialized function
+ // (e.g. Platform::compositorWorkerThread()).
+ m_platformThread = adoptPtr(Platform::current()->createThread("CompositorWorker Thread"));
+ m_thread = WebThreadSupportingGC::createForThread(m_platformThread.get());
}
return *m_thread.get();
}
@@ -102,7 +106,7 @@ void CompositorWorkerManager::shutdownBackingThread()
--m_workerCount;
if (m_workerCount == 0) {
m_thread->shutdown();
- Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(destroyThread, AllowCrossThreadAccess(m_thread.leakPtr())));
+ Platform::current()->mainThread()->postTask(FROM_HERE, threadSafeBind(destroyThread, AllowCrossThreadAccess(m_platformThread.leakPtr())));
m_thread = nullptr;
haraken 2015/09/01 09:32:37 Nit: We may want to run m_thread=nullptr before po
kinuko 2015/09/01 09:48:56 Done.
}
}

Powered by Google App Engine
This is Rietveld 408576698