| 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 #include "platform/scheduler/base/task_queue_impl.h" | 5 #include "platform/scheduler/base/task_queue_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 any_thread().task_queue_manager = nullptr; | 186 any_thread().task_queue_manager = nullptr; |
| 187 main_thread_only().task_queue_manager = nullptr; | 187 main_thread_only().task_queue_manager = nullptr; |
| 188 any_thread().observer = nullptr; | 188 any_thread().observer = nullptr; |
| 189 main_thread_only().observer = nullptr; | 189 main_thread_only().observer = nullptr; |
| 190 main_thread_only().delayed_incoming_queue = std::priority_queue<Task>(); | 190 main_thread_only().delayed_incoming_queue = std::priority_queue<Task>(); |
| 191 immediate_incoming_queue().Clear(); | 191 immediate_incoming_queue().Clear(); |
| 192 main_thread_only().immediate_work_queue.reset(); | 192 main_thread_only().immediate_work_queue.reset(); |
| 193 main_thread_only().delayed_work_queue.reset(); | 193 main_thread_only().delayed_work_queue.reset(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 bool TaskQueueImpl::RunsTasksOnCurrentThread() const { | 196 bool TaskQueueImpl::RunsTasksInCurrentSequence() const { |
| 197 return base::PlatformThread::CurrentId() == thread_id_; | 197 return base::PlatformThread::CurrentId() == thread_id_; |
| 198 } | 198 } |
| 199 | 199 |
| 200 bool TaskQueueImpl::PostDelayedTask(const tracked_objects::Location& from_here, | 200 bool TaskQueueImpl::PostDelayedTask(const tracked_objects::Location& from_here, |
| 201 base::OnceClosure task, | 201 base::OnceClosure task, |
| 202 base::TimeDelta delay) { | 202 base::TimeDelta delay) { |
| 203 if (delay.is_zero()) | 203 if (delay.is_zero()) |
| 204 return PostImmediateTaskImpl(from_here, std::move(task), TaskType::NORMAL); | 204 return PostImmediateTaskImpl(from_here, std::move(task), TaskType::NORMAL); |
| 205 | 205 |
| 206 return PostDelayedTaskImpl(from_here, std::move(task), delay, | 206 return PostDelayedTaskImpl(from_here, std::move(task), delay, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 desired_run_time, sequence_number, | 351 desired_run_time, sequence_number, |
| 352 nestable, sequence_number); | 352 nestable, sequence_number); |
| 353 any_thread().task_queue_manager->DidQueueTask( | 353 any_thread().task_queue_manager->DidQueueTask( |
| 354 immediate_incoming_queue().back()); | 354 immediate_incoming_queue().back()); |
| 355 } | 355 } |
| 356 | 356 |
| 357 if (was_immediate_incoming_queue_empty) { | 357 if (was_immediate_incoming_queue_empty) { |
| 358 // However there's no point posting a DoWork for a blocked queue. NB we can | 358 // However there's no point posting a DoWork for a blocked queue. NB we can |
| 359 // only tell if it's disabled from the main thread. | 359 // only tell if it's disabled from the main thread. |
| 360 bool queue_is_blocked = | 360 bool queue_is_blocked = |
| 361 RunsTasksOnCurrentThread() && | 361 RunsTasksInCurrentSequence() && |
| 362 (!IsQueueEnabled() || main_thread_only().current_fence); | 362 (!IsQueueEnabled() || main_thread_only().current_fence); |
| 363 any_thread().task_queue_manager->OnQueueHasIncomingImmediateWork( | 363 any_thread().task_queue_manager->OnQueueHasIncomingImmediateWork( |
| 364 this, sequence_number, queue_is_blocked); | 364 this, sequence_number, queue_is_blocked); |
| 365 if (any_thread().observer) | 365 if (any_thread().observer) |
| 366 any_thread().observer->OnQueueNextWakeUpChanged(this, desired_run_time); | 366 any_thread().observer->OnQueueNextWakeUpChanged(this, desired_run_time); |
| 367 } | 367 } |
| 368 | 368 |
| 369 TraceQueueSize(); | 369 TraceQueueSize(); |
| 370 } | 370 } |
| 371 | 371 |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 } | 899 } |
| 900 | 900 |
| 901 void TaskQueueImpl::NotifyWakeUpChangedOnMainThread(base::TimeTicks wake_up) { | 901 void TaskQueueImpl::NotifyWakeUpChangedOnMainThread(base::TimeTicks wake_up) { |
| 902 if (main_thread_only().observer) | 902 if (main_thread_only().observer) |
| 903 main_thread_only().observer->OnQueueNextWakeUpChanged(this, wake_up); | 903 main_thread_only().observer->OnQueueNextWakeUpChanged(this, wake_up); |
| 904 } | 904 } |
| 905 | 905 |
| 906 } // namespace internal | 906 } // namespace internal |
| 907 } // namespace scheduler | 907 } // namespace scheduler |
| 908 } // namespace blink | 908 } // namespace blink |
| OLD | NEW |