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

Side by Side Diff: base/test/scoped_async_task_scheduler.h

Issue 2622633004: Add base::test::ScopedAsyncTaskScheduler. (Closed)
Patch Set: CR gab #11 (grammar) Created 3 years, 11 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 | « base/test/BUILD.gn ('k') | base/test/scoped_async_task_scheduler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_
6 #define BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_
7
8 #include "base/macros.h"
9
10 namespace base {
11
12 class TaskScheduler;
13
14 namespace test {
15
16 // Allows usage of the base/task_scheduler/post_task.h API within its scope.
17 // Tasks run asynchronously, one at a time.
18 //
19 // To wait until all posted tasks have run, use
20 // TaskScheduler::GetInstance()->FlushForTesting().
21 //
22 // When possible, use ScopedTaskScheduler instead of this. Tasks posted within
23 // the scope of a ScopedTaskScheduler run synchronously, which makes tests
24 // easier to understand.
25 class ScopedAsyncTaskScheduler {
26 public:
27 // Registers a single-threaded TaskScheduler.
28 ScopedAsyncTaskScheduler();
29
30 // Shuts down and unregisters the TaskScheduler.
31 ~ScopedAsyncTaskScheduler();
32
33 private:
34 const TaskScheduler* task_scheduler_ = nullptr;
35
36 DISALLOW_COPY_AND_ASSIGN(ScopedAsyncTaskScheduler);
37 };
38
39 } // namespace test
40 } // namespace base
41
42 #endif // BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_
OLDNEW
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/scoped_async_task_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698