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

Unified Diff: third_party/WebKit/public/platform/scheduler/base/task_queue.h

Issue 2326313003: Revert of Make canceling Timers fast. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/public/platform/WebTaskRunner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/public/platform/scheduler/base/task_queue.h
diff --git a/third_party/WebKit/public/platform/scheduler/base/task_queue.h b/third_party/WebKit/public/platform/scheduler/base/task_queue.h
index 5612f6e90cde270760bb1b03a117a47a91949554..de0d22ce45eb4f5bf4373b8beef0c3378ac7b9c4 100644
--- a/third_party/WebKit/public/platform/scheduler/base/task_queue.h
+++ b/third_party/WebKit/public/platform/scheduler/base/task_queue.h
@@ -91,6 +91,49 @@
bool should_report_when_execution_blocked;
};
+ // Intended to be used as an opaque handle to a task posted by
+ // PostCancellableDelayedTask.
+ class BLINK_PLATFORM_EXPORT TaskHandle {
+ public:
+ TaskHandle();
+
+ // Returns false if the handle is equivalent to TaskHandle(), i.e. the
+ // handle doesn't represent a task that got posted.
+ operator bool() const;
+
+ private:
+ friend internal::TaskQueueImpl;
+ friend FakeWebTaskRunner;
+
+ // For immediate tasks.
+ TaskHandle(TaskQueue* task_queue, uint64_t enqueue_order);
+
+ // For delayed tasks.
+ TaskHandle(TaskQueue* task_queue,
+ base::TimeTicks scheduled_run_time,
+ int sequence_number);
+
+ uint64_t enqueue_order_;
+ base::TimeTicks scheduled_run_time_;
+#if DCHECK_IS_ON()
+ TaskQueue* task_queue_;
+#endif
+ int sequence_number_;
+ };
+
+ // Posts the given task to be run after |delay| has passed. Returns a handle
+ // which can be passed to CancelTask to cancel the task before it has run.
+ // NOTE this must be called on the thread this TaskQueue was created by.
+ virtual TaskHandle PostCancellableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) = 0;
+
+ // Attempts to cancel a task posted by PostCancellableDelayedTask. Returns
+ // true on success or false otherwise. NOTE this must be called on the thread
+ // this TaskQueue was created by.
+ virtual bool CancelTask(const TaskHandle& handle) = 0;
+
// Enable or disable task execution for this queue. NOTE this must be called
// on the thread this TaskQueue was created by.
virtual void SetQueueEnabled(bool enabled) = 0;
« no previous file with comments | « third_party/WebKit/public/platform/WebTaskRunner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698