| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ |
| 6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ | 6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return *this; | 84 return *this; |
| 85 } | 85 } |
| 86 | 86 |
| 87 const char* name; | 87 const char* name; |
| 88 bool should_monitor_quiescence; | 88 bool should_monitor_quiescence; |
| 89 TimeDomain* time_domain; | 89 TimeDomain* time_domain; |
| 90 bool should_notify_observers; | 90 bool should_notify_observers; |
| 91 bool should_report_when_execution_blocked; | 91 bool should_report_when_execution_blocked; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 // Intended to be used as an opaque handle to a task posted by | |
| 95 // PostCancellableDelayedTask. | |
| 96 class BLINK_PLATFORM_EXPORT TaskHandle { | |
| 97 public: | |
| 98 TaskHandle(); | |
| 99 | |
| 100 // Returns false if the handle is equivalent to TaskHandle(), i.e. the | |
| 101 // handle doesn't represent a task that got posted. | |
| 102 operator bool() const; | |
| 103 | |
| 104 private: | |
| 105 friend internal::TaskQueueImpl; | |
| 106 friend FakeWebTaskRunner; | |
| 107 | |
| 108 // For immediate tasks. | |
| 109 TaskHandle(TaskQueue* task_queue, uint64_t enqueue_order); | |
| 110 | |
| 111 // For delayed tasks. | |
| 112 TaskHandle(TaskQueue* task_queue, | |
| 113 base::TimeTicks scheduled_run_time, | |
| 114 int sequence_number); | |
| 115 | |
| 116 uint64_t enqueue_order_; | |
| 117 base::TimeTicks scheduled_run_time_; | |
| 118 #if DCHECK_IS_ON() | |
| 119 TaskQueue* task_queue_; | |
| 120 #endif | |
| 121 int sequence_number_; | |
| 122 }; | |
| 123 | |
| 124 // Posts the given task to be run after |delay| has passed. Returns a handle | |
| 125 // which can be passed to CancelTask to cancel the task before it has run. | |
| 126 // NOTE this must be called on the thread this TaskQueue was created by. | |
| 127 virtual TaskHandle PostCancellableDelayedTask( | |
| 128 const tracked_objects::Location& from_here, | |
| 129 const base::Closure& task, | |
| 130 base::TimeDelta delay) = 0; | |
| 131 | |
| 132 // Attempts to cancel a task posted by PostCancellableDelayedTask. Returns | |
| 133 // true on success or false otherwise. NOTE this must be called on the thread | |
| 134 // this TaskQueue was created by. | |
| 135 virtual bool CancelTask(const TaskHandle& handle) = 0; | |
| 136 | |
| 137 // Enable or disable task execution for this queue. NOTE this must be called | 94 // Enable or disable task execution for this queue. NOTE this must be called |
| 138 // on the thread this TaskQueue was created by. | 95 // on the thread this TaskQueue was created by. |
| 139 virtual void SetQueueEnabled(bool enabled) = 0; | 96 virtual void SetQueueEnabled(bool enabled) = 0; |
| 140 | 97 |
| 141 // NOTE this must be called on the thread this TaskQueue was created by. | 98 // NOTE this must be called on the thread this TaskQueue was created by. |
| 142 virtual bool IsQueueEnabled() const = 0; | 99 virtual bool IsQueueEnabled() const = 0; |
| 143 | 100 |
| 144 // Returns true if the queue is completely empty. | 101 // Returns true if the queue is completely empty. |
| 145 virtual bool IsEmpty() const = 0; | 102 virtual bool IsEmpty() const = 0; |
| 146 | 103 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 protected: | 151 protected: |
| 195 ~TaskQueue() override {} | 152 ~TaskQueue() override {} |
| 196 | 153 |
| 197 DISALLOW_COPY_AND_ASSIGN(TaskQueue); | 154 DISALLOW_COPY_AND_ASSIGN(TaskQueue); |
| 198 }; | 155 }; |
| 199 | 156 |
| 200 } // namespace scheduler | 157 } // namespace scheduler |
| 201 } // namespace blink | 158 } // namespace blink |
| 202 | 159 |
| 203 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ | 160 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ |
| OLD | NEW |