Index: third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp |
diff --git a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp |
index 78f1ed6beb27b0a324c26fab5deda377eb353b22..bbeef18005882e5b10e3bd522c8f00eca9687102 100644 |
--- a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp |
+++ b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp |
@@ -18,10 +18,12 @@ namespace blink { |
namespace { |
+// Tracks whether we have instantiated a BackingThreadHolder. |
+static bool s_hasBackingThreadHolder = false; |
+ |
// This is a singleton class holding the compositor worker thread in this |
-// renderrer process. BackingThreadHolst::m_thread will never be cleared, |
-// but Oilpan and V8 are detached from the thread when the last compositor |
-// worker thread is gone. |
+// renderrer process. BackingThreadHolst::m_thread is cleared by |
haraken
2016/05/09 02:00:53
renderer
flackr
2016/05/10 18:07:39
Done.
|
+// ModulesInitializer::shutdown. |
// See WorkerThread::terminateAndWaitForAllWorkers for the process shutdown |
// case. |
class BackingThreadHolder { |
@@ -29,10 +31,18 @@ public: |
static BackingThreadHolder& instance() |
{ |
DEFINE_THREAD_SAFE_STATIC_LOCAL(BackingThreadHolder, holder, new BackingThreadHolder); |
+ s_hasBackingThreadHolder = true; |
return holder; |
} |
WorkerBackingThread* thread() { return m_thread.get(); } |
+ static void clear() |
+ { |
+ // Calling instance() if it has not already been called would create |
+ // a backing thread so check if we have an instance first. |
+ if (s_hasBackingThreadHolder) |
haraken
2016/05/09 02:00:53
Just to confirm: The access to s_hasBackingThreadH
flackr
2016/05/10 18:07:39
Right.
|
+ instance().m_thread = nullptr; |
+ } |
void resetForTest() |
{ |
ASSERT(!m_thread || (m_thread->workerScriptCount() == 0)); |
@@ -77,6 +87,16 @@ WorkerGlobalScope*CompositorWorkerThread::createWorkerGlobalScope(PassOwnPtr<Wor |
return CompositorWorkerGlobalScope::create(this, std::move(startupData), m_timeOrigin); |
} |
+void CompositorWorkerThread::ensureSharedBackingThread() |
+{ |
+ BackingThreadHolder::instance(); |
+} |
+ |
+void CompositorWorkerThread::clearSharedBackingThread() |
+{ |
+ BackingThreadHolder::clear(); |
+} |
+ |
void CompositorWorkerThread::resetSharedBackingThreadForTest() |
{ |
BackingThreadHolder::instance().resetForTest(); |