Chromium Code Reviews| 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 "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/trace_event/blame_context.h" | 10 #include "base/trace_event/blame_context.h" |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 bool is_enabled = IsQueueEnabled(); | 796 bool is_enabled = IsQueueEnabled(); |
| 797 if (was_enabled != is_enabled) | 797 if (was_enabled != is_enabled) |
| 798 EnableOrDisableWithSelector(is_enabled); | 798 EnableOrDisableWithSelector(is_enabled); |
| 799 } | 799 } |
| 800 | 800 |
| 801 void TaskQueueImpl::EnableOrDisableWithSelector(bool enable) { | 801 void TaskQueueImpl::EnableOrDisableWithSelector(bool enable) { |
| 802 if (!main_thread_only().task_queue_manager) | 802 if (!main_thread_only().task_queue_manager) |
| 803 return; | 803 return; |
| 804 | 804 |
| 805 if (enable) { | 805 if (enable) { |
| 806 if (!main_thread_only().immediate_work_queue->Empty()) { | |
| 807 main_thread_only().time_domain->OnQueueHasImmediateWork(this); | |
| 808 } else { | |
| 809 base::AutoLock lock(any_thread_lock_); | |
| 810 if (!any_thread().immediate_incoming_queue.empty()) | |
| 811 main_thread_only().time_domain->OnQueueHasImmediateWork(this); | |
|
Sami
2017/02/21 18:21:02
Should we call this outside the lock? Thinking abo
alex clarke (OOO till 29th)
2017/02/21 20:52:30
Done.
| |
| 812 } | |
| 806 if (!main_thread_only().delayed_incoming_queue.empty()) { | 813 if (!main_thread_only().delayed_incoming_queue.empty()) { |
| 807 main_thread_only().time_domain->ScheduleDelayedWork( | 814 main_thread_only().time_domain->ScheduleDelayedWork( |
| 808 this, | 815 this, |
| 809 main_thread_only().delayed_incoming_queue.top().delayed_run_time, | 816 main_thread_only().delayed_incoming_queue.top().delayed_run_time, |
| 810 main_thread_only().time_domain->Now()); | 817 main_thread_only().time_domain->Now()); |
| 811 } | 818 } |
| 812 // Note the selector calls TaskQueueManager::OnTaskQueueEnabled which posts | 819 // Note the selector calls TaskQueueManager::OnTaskQueueEnabled which posts |
| 813 // a DoWork if needed. | 820 // a DoWork if needed. |
| 814 main_thread_only().task_queue_manager->selector_.EnableQueue(this); | 821 main_thread_only().task_queue_manager->selector_.EnableQueue(this); |
| 815 } else { | 822 } else { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 | 868 |
| 862 void TaskQueueImpl::PushImmediateIncomingTaskForTest( | 869 void TaskQueueImpl::PushImmediateIncomingTaskForTest( |
| 863 TaskQueueImpl::Task&& task) { | 870 TaskQueueImpl::Task&& task) { |
| 864 base::AutoLock lock(any_thread_lock_); | 871 base::AutoLock lock(any_thread_lock_); |
| 865 any_thread().immediate_incoming_queue.push_back(std::move(task)); | 872 any_thread().immediate_incoming_queue.push_back(std::move(task)); |
| 866 } | 873 } |
| 867 | 874 |
| 868 } // namespace internal | 875 } // namespace internal |
| 869 } // namespace scheduler | 876 } // namespace scheduler |
| 870 } // namespace blink | 877 } // namespace blink |
| OLD | NEW |