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

Side by Side Diff: base/threading/sequenced_worker_pool_unittest.cc

Issue 2511473004: Create base::test::ScopedTaskScheduler. (Closed)
Patch Set: CR robliao/gab #4-6 Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/threading/sequenced_worker_pool.h" 5 #include "base/threading/sequenced_worker_pool.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 280 }
281 TestTracker* tracker() { return tracker_.get(); } 281 TestTracker* tracker() { return tracker_.get(); }
282 282
283 // Waits until no tasks are running in the SequencedWorkerPool and no 283 // Waits until no tasks are running in the SequencedWorkerPool and no
284 // reference to it remain. Then, destroys the SequencedWorkerPool. 284 // reference to it remain. Then, destroys the SequencedWorkerPool.
285 void DeletePool() { pool_owner_.reset(); } 285 void DeletePool() { pool_owner_.reset(); }
286 286
287 // Destroys and unregisters the registered TaskScheduler, if any. 287 // Destroys and unregisters the registered TaskScheduler, if any.
288 void DeleteTaskScheduler() { 288 void DeleteTaskScheduler() {
289 if (TaskScheduler::GetInstance()) { 289 if (TaskScheduler::GetInstance()) {
290 static_cast<internal::TaskSchedulerImpl*>(TaskScheduler::GetInstance()) 290 TaskScheduler::GetInstance()->JoinForTesting();
291 ->JoinForTesting();
292 TaskScheduler::SetInstance(nullptr); 291 TaskScheduler::SetInstance(nullptr);
293 } 292 }
294 } 293 }
295 294
296 void SetWillWaitForShutdownCallback(const Closure& callback) { 295 void SetWillWaitForShutdownCallback(const Closure& callback) {
297 pool_owner_->SetWillWaitForShutdownCallback(callback); 296 pool_owner_->SetWillWaitForShutdownCallback(callback);
298 } 297 }
299 298
300 // Ensures that the given number of worker threads is created by adding 299 // Ensures that the given number of worker threads is created by adding
301 // tasks and waiting until they complete. Worker thread creation is 300 // tasks and waiting until they complete. Worker thread creation is
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 SequencedWorkerPoolSequencedTaskRunner, SequencedTaskRunnerTest, 1230 SequencedWorkerPoolSequencedTaskRunner, SequencedTaskRunnerTest,
1232 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); 1231 SequencedWorkerPoolSequencedTaskRunnerTestDelegate);
1233 INSTANTIATE_TYPED_TEST_CASE_P( 1232 INSTANTIATE_TYPED_TEST_CASE_P(
1234 SequencedWorkerPoolSequencedTaskRunner, 1233 SequencedWorkerPoolSequencedTaskRunner,
1235 SequencedTaskRunnerDelayedTest, 1234 SequencedTaskRunnerDelayedTest,
1236 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); 1235 SequencedWorkerPoolSequencedTaskRunnerTestDelegate);
1237 1236
1238 } // namespace 1237 } // namespace
1239 1238
1240 } // namespace base 1239 } // namespace base
OLDNEW
« base/test/scoped_task_scheduler.h ('K') | « base/test/scoped_task_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698