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

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

Issue 2066403003: Revert of Remove WorkerBackingThread::scriptCount (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 de797adf0bd59754688ba70c3dbda8872bb9bee5..2458e8af75c6f2bf7796ad32a3655d418342a5f8 100644
--- a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp
+++ b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp
@@ -15,7 +15,6 @@
#include "platform/WaitableEvent.h"
#include "platform/WebThreadSupportingGC.h"
#include "public/platform/Platform.h"
-#include "wtf/Assertions.h"
namespace blink {
@@ -40,10 +39,20 @@
s_instance = new BackingThreadHolder;
}
+ static void terminateExecution()
+ {
+ MutexLocker locker(holderInstanceMutex());
+ if (s_instance && s_instance->m_initialized) {
+ s_instance->thread()->isolate()->TerminateExecution();
+ s_instance->m_terminatingExecution = true;
+ }
+ }
+
static void clear()
{
MutexLocker locker(holderInstanceMutex());
if (s_instance) {
+ DCHECK(!s_instance->m_initialized || s_instance->m_terminatingExecution);
s_instance->shutdownAndWait();
delete s_instance;
s_instance = nullptr;
@@ -76,8 +85,8 @@
void initializeOnThread()
{
MutexLocker locker(holderInstanceMutex());
- DCHECK(!m_initialized);
- m_thread->initialize();
+ DCHECK_EQ(0u, m_thread->workerScriptCount()) << "BackingThreadHolder should be the first to attach to WorkerBackingThread";
+ m_thread->attach();
m_initialized = true;
}
@@ -91,11 +100,13 @@
void shutdownOnThread(WaitableEvent* doneEvent)
{
- m_thread->shutdown();
+ DCHECK_EQ(1u, m_thread->workerScriptCount()) << "BackingThreadHolder should be the last to detach from WorkerBackingThread";
+ m_thread->detach();
doneEvent->signal();
}
OwnPtr<WorkerBackingThread> m_thread;
+ bool m_terminatingExecution = false;
bool m_initialized = false;
static BackingThreadHolder* s_instance;
@@ -140,6 +151,12 @@
BackingThreadHolder::ensureInstance();
}
+void CompositorWorkerThread::terminateExecution()
+{
+ DCHECK(isMainThread());
+ BackingThreadHolder::terminateExecution();
+}
+
void CompositorWorkerThread::clearSharedBackingThread()
{
DCHECK(isMainThread());

Powered by Google App Engine
This is Rietveld 408576698