| 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_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/pending_task.h" | 14 #include "base/pending_task.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "base/trace_event/trace_event_argument.h" | 17 #include "base/trace_event/trace_event_argument.h" |
| 18 #include "platform/scheduler/base/enqueue_order.h" | 18 #include "platform/scheduler/base/enqueue_order.h" |
| 19 #include "platform/scheduler/base/intrusive_heap.h" |
| 19 #include "public/platform/scheduler/base/task_queue.h" | 20 #include "public/platform/scheduler/base/task_queue.h" |
| 20 | 21 |
| 21 namespace blink { | 22 namespace blink { |
| 22 namespace scheduler { | 23 namespace scheduler { |
| 23 class LazyNow; | 24 class LazyNow; |
| 24 class TimeDomain; | 25 class TimeDomain; |
| 25 class TaskQueueManager; | 26 class TaskQueueManager; |
| 26 | 27 |
| 27 namespace internal { | 28 namespace internal { |
| 28 class WorkQueue; | 29 class WorkQueue; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 172 |
| 172 bool should_report_when_execution_blocked() const { | 173 bool should_report_when_execution_blocked() const { |
| 173 return should_report_when_execution_blocked_; | 174 return should_report_when_execution_blocked_; |
| 174 } | 175 } |
| 175 | 176 |
| 176 // Enqueues any delayed tasks which should be run now on the | 177 // Enqueues any delayed tasks which should be run now on the |
| 177 // |delayed_work_queue|. It also schedules the next wake up with the | 178 // |delayed_work_queue|. It also schedules the next wake up with the |
| 178 // TimeDomain. Must be called from the main thread. | 179 // TimeDomain. Must be called from the main thread. |
| 179 void WakeUpForDelayedWork(LazyNow* lazy_now); | 180 void WakeUpForDelayedWork(LazyNow* lazy_now); |
| 180 | 181 |
| 182 base::TimeTicks scheduled_time_domain_wakeup() const { |
| 183 return main_thread_only().scheduled_time_domain_wakeup; |
| 184 } |
| 185 |
| 186 void set_scheduled_time_domain_wakeup( |
| 187 base::TimeTicks scheduled_time_domain_wakeup) { |
| 188 main_thread_only().scheduled_time_domain_wakeup = |
| 189 scheduled_time_domain_wakeup; |
| 190 } |
| 191 |
| 192 HeapHandle heap_handle() const { return main_thread_only().heap_handle; } |
| 193 |
| 194 void set_heap_handle(HeapHandle heap_handle) { |
| 195 main_thread_only().heap_handle = heap_handle; |
| 196 } |
| 197 |
| 181 private: | 198 private: |
| 182 friend class WorkQueue; | 199 friend class WorkQueue; |
| 183 friend class WorkQueueTest; | 200 friend class WorkQueueTest; |
| 184 | 201 |
| 185 enum class TaskType { | 202 enum class TaskType { |
| 186 NORMAL, | 203 NORMAL, |
| 187 NON_NESTABLE, | 204 NON_NESTABLE, |
| 188 }; | 205 }; |
| 189 | 206 |
| 190 struct AnyThread { | 207 struct AnyThread { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 209 // Another copy of TaskQueueManager and TimeDomain for lock-free access from | 226 // Another copy of TaskQueueManager and TimeDomain for lock-free access from |
| 210 // the main thread. See description inside struct AnyThread for details. | 227 // the main thread. See description inside struct AnyThread for details. |
| 211 TaskQueueManager* task_queue_manager; | 228 TaskQueueManager* task_queue_manager; |
| 212 TimeDomain* time_domain; | 229 TimeDomain* time_domain; |
| 213 | 230 |
| 214 std::unique_ptr<WorkQueue> delayed_work_queue; | 231 std::unique_ptr<WorkQueue> delayed_work_queue; |
| 215 std::unique_ptr<WorkQueue> immediate_work_queue; | 232 std::unique_ptr<WorkQueue> immediate_work_queue; |
| 216 std::priority_queue<Task> delayed_incoming_queue; | 233 std::priority_queue<Task> delayed_incoming_queue; |
| 217 base::ObserverList<base::MessageLoop::TaskObserver> task_observers; | 234 base::ObserverList<base::MessageLoop::TaskObserver> task_observers; |
| 218 size_t set_index; | 235 size_t set_index; |
| 236 HeapHandle heap_handle; |
| 219 bool is_enabled; | 237 bool is_enabled; |
| 220 base::trace_event::BlameContext* blame_context; // Not owned. | 238 base::trace_event::BlameContext* blame_context; // Not owned. |
| 221 EnqueueOrder current_fence; | 239 EnqueueOrder current_fence; |
| 240 base::TimeTicks scheduled_time_domain_wakeup; |
| 222 }; | 241 }; |
| 223 | 242 |
| 224 ~TaskQueueImpl() override; | 243 ~TaskQueueImpl() override; |
| 225 | 244 |
| 226 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, | 245 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, |
| 227 const base::Closure& task, | 246 const base::Closure& task, |
| 228 TaskType task_type); | 247 TaskType task_type); |
| 229 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, | 248 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, |
| 230 const base::Closure& task, | 249 const base::Closure& task, |
| 231 base::TimeDelta delay, | 250 base::TimeDelta delay, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 const bool should_report_when_execution_blocked_; | 317 const bool should_report_when_execution_blocked_; |
| 299 | 318 |
| 300 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); | 319 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); |
| 301 }; | 320 }; |
| 302 | 321 |
| 303 } // namespace internal | 322 } // namespace internal |
| 304 } // namespace scheduler | 323 } // namespace scheduler |
| 305 } // namespace blink | 324 } // namespace blink |
| 306 | 325 |
| 307 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 326 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| OLD | NEW |