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