| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 desired_run_time, sequence_number, | 355 desired_run_time, sequence_number, |
| 356 nestable, sequence_number); | 356 nestable, sequence_number); |
| 357 any_thread().task_queue_manager->DidQueueTask( | 357 any_thread().task_queue_manager->DidQueueTask( |
| 358 immediate_incoming_queue().back()); | 358 immediate_incoming_queue().back()); |
| 359 } | 359 } |
| 360 | 360 |
| 361 if (was_immediate_incoming_queue_empty) { | 361 if (was_immediate_incoming_queue_empty) { |
| 362 // However there's no point posting a DoWork for a blocked queue. NB we can | 362 // However there's no point posting a DoWork for a blocked queue. NB we can |
| 363 // only tell if it's disabled from the main thread. | 363 // only tell if it's disabled from the main thread. |
| 364 bool queue_is_blocked = | 364 bool queue_is_blocked = |
| 365 RunsTasksOnCurrentThread() && | 365 RunsTasksInCurrentSequence() && |
| 366 (!IsQueueEnabled() || main_thread_only().current_fence); | 366 (!IsQueueEnabled() || main_thread_only().current_fence); |
| 367 any_thread().task_queue_manager->OnQueueHasIncomingImmediateWork( | 367 any_thread().task_queue_manager->OnQueueHasIncomingImmediateWork( |
| 368 this, sequence_number, queue_is_blocked); | 368 this, sequence_number, queue_is_blocked); |
| 369 if (any_thread().observer) | 369 if (any_thread().observer) |
| 370 any_thread().observer->OnQueueNextWakeUpChanged(this, desired_run_time); | 370 any_thread().observer->OnQueueNextWakeUpChanged(this, desired_run_time); |
| 371 } | 371 } |
| 372 | 372 |
| 373 TraceQueueSize(); | 373 TraceQueueSize(); |
| 374 } | 374 } |
| 375 | 375 |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 } | 903 } |
| 904 | 904 |
| 905 void TaskQueueImpl::NotifyWakeUpChangedOnMainThread(base::TimeTicks wake_up) { | 905 void TaskQueueImpl::NotifyWakeUpChangedOnMainThread(base::TimeTicks wake_up) { |
| 906 if (main_thread_only().observer) | 906 if (main_thread_only().observer) |
| 907 main_thread_only().observer->OnQueueNextWakeUpChanged(this, wake_up); | 907 main_thread_only().observer->OnQueueNextWakeUpChanged(this, wake_up); |
| 908 } | 908 } |
| 909 | 909 |
| 910 } // namespace internal | 910 } // namespace internal |
| 911 } // namespace scheduler | 911 } // namespace scheduler |
| 912 } // namespace blink | 912 } // namespace blink |
| OLD | NEW |