OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_manager.h" | 5 #include "platform/scheduler/base/task_queue_manager.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // Converts a OnceClosure to a RepeatingClosure. It hits CHECK failure to run | 42 // Converts a OnceClosure to a RepeatingClosure. It hits CHECK failure to run |
43 // the resulting RepeatingClosure more than once. | 43 // the resulting RepeatingClosure more than once. |
44 // TODO(tzik): This will be unneeded after the Closure-to-OnceClosure migration | 44 // TODO(tzik): This will be unneeded after the Closure-to-OnceClosure migration |
45 // on TaskRunner finished. Remove it once it gets unneeded. | 45 // on TaskRunner finished. Remove it once it gets unneeded. |
46 base::RepeatingClosure UnsafeConvertOnceClosureToRepeating( | 46 base::RepeatingClosure UnsafeConvertOnceClosureToRepeating( |
47 base::OnceClosure cb) { | 47 base::OnceClosure cb) { |
48 return base::BindRepeating([](base::OnceClosure cb) { std::move(cb).Run(); }, | 48 return base::BindRepeating([](base::OnceClosure cb) { std::move(cb).Run(); }, |
49 base::Passed(&cb)); | 49 base::Passed(&cb)); |
50 } | 50 } |
51 } | 51 } // namespace |
52 | 52 |
53 TaskQueueManager::TaskQueueManager( | 53 TaskQueueManager::TaskQueueManager( |
54 scoped_refptr<TaskQueueManagerDelegate> delegate) | 54 scoped_refptr<TaskQueueManagerDelegate> delegate) |
55 : real_time_domain_(new RealTimeDomain()), | 55 : real_time_domain_(new RealTimeDomain()), |
56 delegate_(delegate), | 56 delegate_(delegate), |
57 task_was_run_on_quiescence_monitored_queue_(false), | 57 task_was_run_on_quiescence_monitored_queue_(false), |
58 record_task_delay_histograms_(true), | 58 record_task_delay_histograms_(true), |
59 work_batch_size_(1), | 59 work_batch_size_(1), |
60 task_count_(0), | 60 task_count_(0), |
61 currently_executing_task_queue_(nullptr), | 61 currently_executing_task_queue_(nullptr), |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 currently_executing_task_queue_; | 529 currently_executing_task_queue_; |
530 currently_executing_task_queue_ = queue; | 530 currently_executing_task_queue_ = queue; |
531 task_annotator_.RunTask("TaskQueueManager::PostTask", &pending_task); | 531 task_annotator_.RunTask("TaskQueueManager::PostTask", &pending_task); |
532 // Detect if the TaskQueueManager just got deleted. If this happens we must | 532 // Detect if the TaskQueueManager just got deleted. If this happens we must |
533 // not access any member variables after this point. | 533 // not access any member variables after this point. |
534 if (protect->HasOneRef()) | 534 if (protect->HasOneRef()) |
535 return ProcessTaskResult::TASK_QUEUE_MANAGER_DELETED; | 535 return ProcessTaskResult::TASK_QUEUE_MANAGER_DELETED; |
536 | 536 |
537 currently_executing_task_queue_ = prev_executing_task_queue; | 537 currently_executing_task_queue_ = prev_executing_task_queue; |
538 | 538 |
539 | |
540 if (queue->GetShouldNotifyObservers()) { | 539 if (queue->GetShouldNotifyObservers()) { |
541 if (task_start_time) { | 540 if (task_start_time) { |
542 *time_after_task = real_time_domain()->Now(); | 541 *time_after_task = real_time_domain()->Now(); |
543 double task_end_time = MonotonicTimeInSeconds(*time_after_task); | 542 double task_end_time = MonotonicTimeInSeconds(*time_after_task); |
544 for (auto& observer : task_time_observers_) | 543 for (auto& observer : task_time_observers_) |
545 observer.DidProcessTask(queue, task_start_time, task_end_time); | 544 observer.DidProcessTask(queue, task_start_time, task_end_time); |
546 } | 545 } |
547 | 546 |
548 for (auto& observer : task_observers_) | 547 for (auto& observer : task_observers_) |
549 observer.DidProcessTask(pending_task); | 548 observer.DidProcessTask(pending_task); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 for (const scoped_refptr<internal::TaskQueueImpl>& queue : queues_) { | 703 for (const scoped_refptr<internal::TaskQueueImpl>& queue : queues_) { |
705 TimeDomain* time_domain = queue->GetTimeDomain(); | 704 TimeDomain* time_domain = queue->GetTimeDomain(); |
706 if (time_domain_now.find(time_domain) == time_domain_now.end()) | 705 if (time_domain_now.find(time_domain) == time_domain_now.end()) |
707 time_domain_now.insert(std::make_pair(time_domain, time_domain->Now())); | 706 time_domain_now.insert(std::make_pair(time_domain, time_domain->Now())); |
708 queue->SweepCanceledDelayedTasks(time_domain_now[time_domain]); | 707 queue->SweepCanceledDelayedTasks(time_domain_now[time_domain]); |
709 } | 708 } |
710 } | 709 } |
711 | 710 |
712 } // namespace scheduler | 711 } // namespace scheduler |
713 } // namespace blink | 712 } // namespace blink |
OLD | NEW |