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

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: 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..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

Powered by Google App Engine
This is Rietveld 408576698