Index: Source/platform/scheduler/CancellableTaskFactory.cpp |
diff --git a/Source/platform/scheduler/CancellableTaskFactory.cpp b/Source/platform/scheduler/CancellableTaskFactory.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..083852510f9d05c78d51c556d876b3979bfa7e8b |
--- /dev/null |
+++ b/Source/platform/scheduler/CancellableTaskFactory.cpp |
@@ -0,0 +1,37 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "platform/scheduler/CancellableTaskFactory.h" |
+ |
+#include "platform/TraceLocation.h" |
+#include "public/platform/Platform.h" |
+#include "wtf/InstanceCounter.h" |
+ |
+namespace blink { |
+ |
+void CancellableTaskFactory::cancel() |
+{ |
+ m_weakPtrFactory.revokeAll(); |
+} |
+ |
+WebThread::Task* CancellableTaskFactory::task() |
+{ |
+ m_weakPtrFactory.revokeAll(); |
Sami
2015/01/26 16:08:14
Perhaps just call cancel() here instead of duplica
alex clarke (OOO till 29th)
2015/01/26 17:00:45
Done.
|
+ return new CancellableTask(m_weakPtrFactory.createWeakPtr()); |
+} |
+ |
+void CancellableTaskFactory::CancellableTask::run() |
+{ |
+ if (m_weakPtr.get()) |
+ m_weakPtr->runInternal(); |
Sami
2015/01/26 16:08:14
nit: I think you could call m_closure here directl
alex clarke (OOO till 29th)
2015/01/26 17:00:45
Done.
|
+} |
+ |
+void CancellableTaskFactory::runInternal() |
+{ |
+ m_weakPtrFactory.revokeAll(); |
Sami
2015/01/26 16:08:14
Do we need to do this? Task::run is guaranteed to
alex clarke (OOO till 29th)
2015/01/26 17:00:45
Yes we do because there's code in the HTML parser
|
+ (*m_closure)(); |
+} |
+ |
+} // namespace blink |