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

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..9e57554a5ff6285f4cd9d0db7b3df3984599d4dc 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 take over CancellableTaskFactory.
dcheng 2016/10/21 06:14:46 Nit: take over => replace
tzik 2016/10/25 07:03:52 Done.
+// 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.
dcheng 2016/10/21 06:14:46 Hmm, that's unfortunate. That means that something
tzik 2016/10/25 07:03:52 It hopefully doesn't make big difference. I expect
+
namespace blink {
class TraceLocation;

Powered by Google App Engine
This is Rietveld 408576698