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

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

Issue 876623002: Adds a CancellableTaskFactory and exposes postLoadingTasks to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 11 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
new file mode 100644
index 0000000000000000000000000000000000000000..4fd4ae29ae61c636e6e7c51929b3220dc2944c91
--- /dev/null
+++ b/Source/platform/scheduler/CancellableTaskFactory.cpp
@@ -0,0 +1,34 @@
+// 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()
+{
+ cancel();
+ return new CancellableTask(m_weakPtrFactory.createWeakPtr());
+}
+
+void CancellableTaskFactory::CancellableTask::run()
+{
+ if (m_weakPtr.get()) {
+ Closure* closure = m_weakPtr->m_closure.get();
+ m_weakPtr->m_weakPtrFactory.revokeAll();
+ (*closure)();
+ }
+}
+
+} // namespace blink
« no previous file with comments | « Source/platform/scheduler/CancellableTaskFactory.h ('k') | Source/platform/scheduler/CancellableTaskFactoryTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698