Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Side by Side Diff: base/test/scoped_task_scheduler.cc

Issue 2750823002: Flush TaskScheduler in content::RunAllBlockingPoolTasksUntilIdle(). (Closed)
Patch Set: add rununtilidle in TestTaskScheduler::FlushForTesting Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/public/test/test_utils.h » ('j') | content/public/test/test_utils.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | content/public/test/test_utils.h » ('j') | content/public/test/test_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698