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

Unified Diff: Source/platform/scheduler/CancellableTaskFactory.cpp

Issue 956333002: Refactor TimeBase to post tasks. Workers to use real Idle tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix a bunch of stuff Created 5 years, 10 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/platform/scheduler/CancellableTaskFactory.cpp
diff --git a/Source/platform/scheduler/CancellableTaskFactory.cpp b/Source/platform/scheduler/CancellableTaskFactory.cpp
index a7c81e39de2b542e0b56b3c5d03e3bdbad38f44a..4efe10f8bdf4d0025e086324e205be55d3b0efbf 100644
--- a/Source/platform/scheduler/CancellableTaskFactory.cpp
+++ b/Source/platform/scheduler/CancellableTaskFactory.cpp
@@ -5,28 +5,34 @@
#include "config.h"
#include "platform/scheduler/CancellableTaskFactory.h"
-#include "public/platform/Platform.h"
-#include "wtf/InstanceCounter.h"
-
namespace blink {
void CancellableTaskFactory::cancel()
{
- m_weakPtrFactory.revokeAll();
+ ASSERT(m_thread == currentThread());
+
+ if (m_task) {
+ m_task->cancel();
+ m_task = nullptr;
+ }
}
WebThread::Task* CancellableTaskFactory::task()
{
+ ASSERT(m_thread == currentThread());
+
cancel();
- return new CancellableTask(m_weakPtrFactory.createWeakPtr());
+ m_task = new CancellableTask(this);
+ return m_task;
}
void CancellableTaskFactory::CancellableTask::run()
{
- if (m_weakPtr.get()) {
- Closure* closure = m_weakPtr->m_closure.get();
- m_weakPtr->m_weakPtrFactory.revokeAll();
- (*closure)();
+ if (m_factory) {
+ ASSERT(m_factory->m_thread == currentThread());
+ m_factory->m_task = nullptr;
+ (*m_factory->m_closure)();
+ m_factory = nullptr;
}
}

Powered by Google App Engine
This is Rietveld 408576698