| 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/test/scoped_task_scheduler.h" | 5 #include "base/test/scoped_task_scheduler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 void TestTaskScheduler::Shutdown() { | 215 void TestTaskScheduler::Shutdown() { |
| 216 // Prevent SKIP_ON_SHUTDOWN and CONTINUE_ON_SHUTDOWN tasks from running from | 216 // Prevent SKIP_ON_SHUTDOWN and CONTINUE_ON_SHUTDOWN tasks from running from |
| 217 // now on. | 217 // now on. |
| 218 task_tracker_.SetHasShutdownStartedForTesting(); | 218 task_tracker_.SetHasShutdownStartedForTesting(); |
| 219 | 219 |
| 220 // Run pending BLOCK_SHUTDOWN tasks. | 220 // Run pending BLOCK_SHUTDOWN tasks. |
| 221 RunLoop().RunUntilIdle(); | 221 RunLoop().RunUntilIdle(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void TestTaskScheduler::FlushForTesting() { | 224 void TestTaskScheduler::FlushForTesting() { |
| 225 NOTREACHED(); | 225 RunLoop().RunUntilIdle(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void TestTaskScheduler::JoinForTesting() { | 228 void TestTaskScheduler::JoinForTesting() { |
| 229 // TestTaskScheduler doesn't create threads so this does nothing. | 229 // TestTaskScheduler doesn't create threads so this does nothing. |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool TestTaskScheduler::PostTask(std::unique_ptr<internal::Task> task, | 232 bool TestTaskScheduler::PostTask(std::unique_ptr<internal::Task> task, |
| 233 const SequenceToken& sequence_token) { | 233 const SequenceToken& sequence_token) { |
| 234 DCHECK(task); | 234 DCHECK(task); |
| 235 if (!task_tracker_.WillPostTask(task.get())) | 235 if (!task_tracker_.WillPostTask(task.get())) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 DCHECK_EQ(task_scheduler_, TaskScheduler::GetInstance()); | 322 DCHECK_EQ(task_scheduler_, TaskScheduler::GetInstance()); |
| 323 | 323 |
| 324 // Per contract, call JoinForTesting() before deleting the TaskScheduler. | 324 // Per contract, call JoinForTesting() before deleting the TaskScheduler. |
| 325 TaskScheduler::GetInstance()->JoinForTesting(); | 325 TaskScheduler::GetInstance()->JoinForTesting(); |
| 326 | 326 |
| 327 TaskScheduler::SetInstance(nullptr); | 327 TaskScheduler::SetInstance(nullptr); |
| 328 } | 328 } |
| 329 | 329 |
| 330 } // namespace test | 330 } // namespace test |
| 331 } // namespace base | 331 } // namespace base |
| OLD | NEW |