Index: third_party/WebKit/Source/platform/WebTaskRunner.cpp |
diff --git a/third_party/WebKit/Source/platform/WebTaskRunner.cpp b/third_party/WebKit/Source/platform/WebTaskRunner.cpp |
index 059abdf83d05f66c7baf472599d312d4509ab646..2e800aee93f7afd21a026284e34fc7d516adf287 100644 |
--- a/third_party/WebKit/Source/platform/WebTaskRunner.cpp |
+++ b/third_party/WebKit/Source/platform/WebTaskRunner.cpp |
@@ -4,8 +4,29 @@ |
#include "platform/WebTaskRunner.h" |
+#include "base/bind_helpers.h" |
#include "base/single_thread_task_runner.h" |
+namespace base { |
+ |
+using RunnerMethodType = |
+ void (blink::TaskHandle::Runner::*)(const blink::TaskHandle&); |
+ |
+template <> |
+struct BindCancellationChecker< |
+ RunnerMethodType, |
+ std::tuple<WTF::WeakPtr<blink::TaskHandle::Runner>, blink::TaskHandle>> { |
+ static constexpr bool is_cancellable = true; |
+ |
+ static bool Run(RunnerMethodType, |
+ const WTF::WeakPtr<blink::TaskHandle::Runner>&, |
+ const blink::TaskHandle& handle) { |
+ return !handle.isActive(); |
+ } |
+}; |
+ |
+} // namespace base |
+ |
namespace blink { |
class TaskHandle::Runner : public WTF::ThreadSafeRefCounted<Runner> { |
@@ -15,7 +36,7 @@ class TaskHandle::Runner : public WTF::ThreadSafeRefCounted<Runner> { |
WTF::WeakPtr<Runner> asWeakPtr() { return m_weakPtrFactory.createWeakPtr(); } |
- bool isActive() { return static_cast<bool>(m_task); } |
+ bool isActive() const { return m_task && !m_task->isCancelled(); } |
void cancel() { |
std::unique_ptr<WTF::Closure> task = std::move(m_task); |