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

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

Issue 2304073002: LeakDetector should run a GC on the compositor thread (Closed)
Patch Set: fix Created 4 years, 3 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/AbstractAnimationWorkletThread.cpp
diff --git a/third_party/WebKit/Source/modules/compositorworker/AbstractAnimationWorkletThread.cpp b/third_party/WebKit/Source/modules/compositorworker/AbstractAnimationWorkletThread.cpp
index 731dd693e8691c0f3557e83829f8f74cd818d50d..c27f2944f2231daef6fe51779e0a3e3de8ec05f1 100644
--- a/third_party/WebKit/Source/modules/compositorworker/AbstractAnimationWorkletThread.cpp
+++ b/third_party/WebKit/Source/modules/compositorworker/AbstractAnimationWorkletThread.cpp
@@ -24,10 +24,10 @@ namespace {
// case.
class BackingThreadHolder {
public:
- static BackingThreadHolder& instance()
+ static BackingThreadHolder* instance()
{
MutexLocker locker(holderInstanceMutex());
- return *s_instance;
+ return s_instance;
}
static void ensureInstance()
@@ -112,7 +112,24 @@ AbstractAnimationWorkletThread::~AbstractAnimationWorkletThread()
WorkerBackingThread& AbstractAnimationWorkletThread::workerBackingThread()
{
- return *BackingThreadHolder::instance().thread();
+ return *BackingThreadHolder::instance()->thread();
+}
+
+void collectAllGarbageOnThread(WaitableEvent* doneEvent)
+{
+ blink::ThreadState::current()->collectAllGarbage();
+ doneEvent->signal();
+}
+
+void AbstractAnimationWorkletThread::collectAllGarbage()
+{
+ DCHECK(isMainThread());
+ WaitableEvent doneEvent;
+ BackingThreadHolder* instance = BackingThreadHolder::instance();
+ if (!instance)
+ return;
+ instance->thread()->backingThread().postTask(BLINK_FROM_HERE, crossThreadBind(&collectAllGarbageOnThread, crossThreadUnretained(&doneEvent)));
+ doneEvent.wait();
}
void AbstractAnimationWorkletThread::ensureSharedBackingThread()

Powered by Google App Engine
This is Rietveld 408576698