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

Unified Diff: third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp

Issue 1955693003: compositor-worker: Keep worker backing thread alive for the lifetime of the compositor thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Expand on comments. Created 4 years, 7 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: 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..39383d21734c8a107183a88521a024eb23fe26fd 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.
+// renderer process. BackingThreadHolder::m_thread is cleared by
+// 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;
yhirano 2016/05/11 02:21:02 You need to protect the boolean with a mutex.
flackr 2016/05/18 05:26:50 Why does this need to be protected, aren't instanc
return holder;
}
WorkerBackingThread* thread() { return m_thread.get(); }
+ static void clear()
+ {
+ // Calling instance() if it has not already been called would create
yhirano 2016/05/11 02:21:02 ditto
+ // a backing thread so check if we have an instance first.
+ if (s_hasBackingThreadHolder)
+ 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();

Powered by Google App Engine
This is Rietveld 408576698