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

Unified Diff: Source/core/workers/WorkerThread.cpp

Issue 617023003: Revert of [Blink-WebWorkers] WorkerSharedTimer cancels extra delayed tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « LayoutTests/fast/workers/worker-timeout-increasing-order-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/WorkerThread.cpp
diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp
index 6a4ba101005434cbe96cdc2f9389af5082bb8e4a..166679e448d1e49897a71187389409c8dec51f31 100644
--- a/Source/core/workers/WorkerThread.cpp
+++ b/Source/core/workers/WorkerThread.cpp
@@ -85,39 +85,12 @@
return workerThreads().size();
}
-class WorkerThreadCancelableTask FINAL : public ExecutionContextTask {
- WTF_MAKE_NONCOPYABLE(WorkerThreadCancelableTask); WTF_MAKE_FAST_ALLOCATED;
-public:
- static PassOwnPtr<WorkerThreadCancelableTask> create(const Closure& closure)
- {
- return adoptPtr(new WorkerThreadCancelableTask(closure));
- }
-
- virtual void performTask(ExecutionContext*) OVERRIDE
- {
- if (!m_taskCanceled)
- m_closure();
- }
-
- void cancelTask() { m_taskCanceled = true; }
-
-private:
- explicit WorkerThreadCancelableTask(const Closure& closure)
- : m_closure(closure)
- , m_taskCanceled(false)
- { }
-
- Closure m_closure;
- bool m_taskCanceled;
-};
-
class WorkerSharedTimer : public SharedTimer {
public:
explicit WorkerSharedTimer(WorkerThread* workerThread)
: m_workerThread(workerThread)
, m_nextFireTime(0.0)
, m_running(false)
- , m_lastQueuedTask(0)
{ }
typedef void (*SharedTimerFunction)();
@@ -143,21 +116,12 @@
m_running = true;
m_nextFireTime = currentTime() + interval;
-
- if (m_lastQueuedTask)
- m_lastQueuedTask->cancelTask();
-
- // Now queue the task as a cancellable one.
- m_lastQueuedTask = WorkerThreadCancelableTask::create(bind(&WorkerSharedTimer::OnTimeout, this)).leakPtr();
- m_workerThread->postDelayedTask(adoptPtr(m_lastQueuedTask), delay);
+ m_workerThread->postDelayedTask(createSameThreadTask(&WorkerSharedTimer::OnTimeout, this), delay);
}
virtual void stop()
{
m_running = false;
- if (m_lastQueuedTask)
- m_lastQueuedTask->cancelTask();
- m_lastQueuedTask = 0;
}
double nextFireTime() { return m_nextFireTime; }
@@ -166,9 +130,6 @@
void OnTimeout()
{
ASSERT(m_workerThread->workerGlobalScope());
-
- m_lastQueuedTask = 0;
-
if (m_sharedTimerFunction && m_running && !m_workerThread->workerGlobalScope()->isClosing())
m_sharedTimerFunction();
}
@@ -177,7 +138,6 @@
SharedTimerFunction m_sharedTimerFunction;
double m_nextFireTime;
bool m_running;
- WorkerThreadCancelableTask* m_lastQueuedTask;
};
class WorkerThreadTask : public blink::WebThread::Task {
« no previous file with comments | « LayoutTests/fast/workers/worker-timeout-increasing-order-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698