| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/task_scheduler/task_tracker.h" | 5 #include "base/task_scheduler/task_tracker.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/debug/task_annotator.h" | 8 #include "base/debug/task_annotator.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // posted during shutdown. Otherwise, the histogram has already been recorded | 52 // posted during shutdown. Otherwise, the histogram has already been recorded |
| 53 // in BeforePostTask(). | 53 // in BeforePostTask(). |
| 54 if (num_block_shutdown_tasks_posted_during_shutdown_ < | 54 if (num_block_shutdown_tasks_posted_during_shutdown_ < |
| 55 kMaxBlockShutdownTasksPostedDuringShutdown) { | 55 kMaxBlockShutdownTasksPostedDuringShutdown) { |
| 56 RecordNumBlockShutdownTasksPostedDuringShutdown( | 56 RecordNumBlockShutdownTasksPostedDuringShutdown( |
| 57 num_block_shutdown_tasks_posted_during_shutdown_); | 57 num_block_shutdown_tasks_posted_during_shutdown_); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 void TaskTracker::PostTask( | 61 void TaskTracker::PostTask( |
| 62 const Callback<void(scoped_ptr<Task>)>& post_task_callback, | 62 const Callback<void(std::unique_ptr<Task>)>& post_task_callback, |
| 63 scoped_ptr<Task> task) { | 63 std::unique_ptr<Task> task) { |
| 64 DCHECK(!post_task_callback.is_null()); | 64 DCHECK(!post_task_callback.is_null()); |
| 65 DCHECK(task); | 65 DCHECK(task); |
| 66 | 66 |
| 67 if (!BeforePostTask(task->traits.shutdown_behavior())) | 67 if (!BeforePostTask(task->traits.shutdown_behavior())) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 debug::TaskAnnotator task_annotator; | 70 debug::TaskAnnotator task_annotator; |
| 71 task_annotator.DidQueueTask(kQueueFunctionName, *task); | 71 task_annotator.DidQueueTask(kQueueFunctionName, *task); |
| 72 | 72 |
| 73 post_task_callback.Run(std::move(task)); | 73 post_task_callback.Run(std::move(task)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 AutoSchedulerLock auto_lock(lock_); | 174 AutoSchedulerLock auto_lock(lock_); |
| 175 DCHECK_GT(num_tasks_blocking_shutdown_, 0U); | 175 DCHECK_GT(num_tasks_blocking_shutdown_, 0U); |
| 176 --num_tasks_blocking_shutdown_; | 176 --num_tasks_blocking_shutdown_; |
| 177 if (num_tasks_blocking_shutdown_ == 0 && shutdown_cv_) | 177 if (num_tasks_blocking_shutdown_ == 0 && shutdown_cv_) |
| 178 shutdown_cv_->Signal(); | 178 shutdown_cv_->Signal(); |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace internal | 182 } // namespace internal |
| 183 } // namespace base | 183 } // namespace base |
| OLD | NEW |