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

Unified Diff: third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h

Issue 2353913005: Add WebTaskRunner::postCancellableTask (Closed)
Patch Set: . Created 4 years, 2 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: third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h
diff --git a/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h b/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h
index e37af101b2859ab6c5bfc2b7009360ec4f14d345..19111dd19aeb8b5a5e930ca9ea6eb90026daccff 100644
--- a/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h
+++ b/third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h
@@ -16,6 +16,26 @@
#include <memory>
#include <type_traits>
+// WebTaskRunner::postCancellableTask will replace CancellableTaskFactory.
+// Use postCancellableTask in new code.
+// Example: For |task_runner| and |foo| below.
+// WebTaskRunner* task_runner;
+// Foo* foo;
+//
+// CancellableTaskFactory factory(foo, &Foo::bar);
+// task_runner->postTask(BLINK_FROM_HERE, factory.cancelAndCreate());
+// factory.cancel();
+//
+// Above is equivalent to below:
+//
+// std::unique_ptr<WTF::Closure> task =
+// WTF::bind(wrapPersistent(foo), &Foo::bar);
+// RefPtr<TaskHandle> handle =
+// task_runner->postCancellableTask(BLINK_FROM_HERE, std::move(task));
+// handle->cancel();
+//
+// Note that the task is not automatically cancelled on TaskHandle scope out.
Sami 2016/10/26 12:32:51 Is the last sentence still accurate?
tzik 2016/10/27 06:38:53 Yes, it's mostly still valid. Added a comment to m
+
namespace blink {
class TraceLocation;

Powered by Google App Engine
This is Rietveld 408576698