| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 void TestTaskScheduler::Shutdown() { | 181 void TestTaskScheduler::Shutdown() { |
| 182 // Prevent SKIP_ON_SHUTDOWN and CONTINUE_ON_SHUTDOWN tasks from running from | 182 // Prevent SKIP_ON_SHUTDOWN and CONTINUE_ON_SHUTDOWN tasks from running from |
| 183 // now on. | 183 // now on. |
| 184 task_tracker_.SetHasShutdownStartedForTesting(); | 184 task_tracker_.SetHasShutdownStartedForTesting(); |
| 185 | 185 |
| 186 // Run pending BLOCK_SHUTDOWN tasks. | 186 // Run pending BLOCK_SHUTDOWN tasks. |
| 187 RunLoop().RunUntilIdle(); | 187 RunLoop().RunUntilIdle(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void TestTaskScheduler::FlushForTesting() { | 190 void TestTaskScheduler::FlushForTesting() { |
| 191 NOTREACHED(); | 191 RunLoop().RunUntilIdle(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void TestTaskScheduler::JoinForTesting() { | 194 void TestTaskScheduler::JoinForTesting() { |
| 195 // TestTaskScheduler doesn't create threads so this does nothing. | 195 // TestTaskScheduler doesn't create threads so this does nothing. |
| 196 } | 196 } |
| 197 | 197 |
| 198 bool TestTaskScheduler::PostTask(std::unique_ptr<internal::Task> task, | 198 bool TestTaskScheduler::PostTask(std::unique_ptr<internal::Task> task, |
| 199 const SequenceToken& sequence_token) { | 199 const SequenceToken& sequence_token) { |
| 200 DCHECK(task); | 200 DCHECK(task); |
| 201 if (!task_tracker_.WillPostTask(task.get())) | 201 if (!task_tracker_.WillPostTask(task.get())) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 DCHECK_EQ(task_scheduler_, TaskScheduler::GetInstance()); | 287 DCHECK_EQ(task_scheduler_, TaskScheduler::GetInstance()); |
| 288 | 288 |
| 289 // Per contract, call JoinForTesting() before deleting the TaskScheduler. | 289 // Per contract, call JoinForTesting() before deleting the TaskScheduler. |
| 290 TaskScheduler::GetInstance()->JoinForTesting(); | 290 TaskScheduler::GetInstance()->JoinForTesting(); |
| 291 | 291 |
| 292 TaskScheduler::SetInstance(nullptr); | 292 TaskScheduler::SetInstance(nullptr); |
| 293 } | 293 } |
| 294 | 294 |
| 295 } // namespace test | 295 } // namespace test |
| 296 } // namespace base | 296 } // namespace base |
| OLD | NEW |