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

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

Issue 2885783002: Add ScopedTaskEnvironment::GetMainThreadTaskRunner(). (Closed)
Patch Set: self-review Created 3 years, 7 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 | base/test/scoped_task_environment.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 #ifndef BASE_TEST_SCOPED_TASK_ENVIRONMENT_H_ 5 #ifndef BASE_TEST_SCOPED_TASK_ENVIRONMENT_H_
6 #define BASE_TEST_SCOPED_TASK_ENVIRONMENT_H_ 6 #define BASE_TEST_SCOPED_TASK_ENVIRONMENT_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/single_thread_task_runner.h"
10 11
11 namespace base { 12 namespace base {
12 13
13 class TaskScheduler; 14 class TaskScheduler;
14 15
15 namespace test { 16 namespace test {
16 17
17 // ScopedTaskEnvironment allows usage of these APIs within its scope: 18 // ScopedTaskEnvironment allows usage of these APIs within its scope:
18 // - (Thread|Sequenced)TaskRunnerHandle, on the thread where it lives 19 // - (Thread|Sequenced)TaskRunnerHandle, on the thread where it lives
19 // - base/task_scheduler/post_task.h, on any thread 20 // - base/task_scheduler/post_task.h, on any thread
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 IO, 61 IO,
61 }; 62 };
62 63
63 ScopedTaskEnvironment( 64 ScopedTaskEnvironment(
64 MainThreadType main_thread_type = MainThreadType::DEFAULT); 65 MainThreadType main_thread_type = MainThreadType::DEFAULT);
65 66
66 // Waits until no undelayed TaskScheduler tasks remain. Then, unregisters the 67 // Waits until no undelayed TaskScheduler tasks remain. Then, unregisters the
67 // TaskScheduler and the (Thread|Sequenced)TaskRunnerHandle. 68 // TaskScheduler and the (Thread|Sequenced)TaskRunnerHandle.
68 ~ScopedTaskEnvironment(); 69 ~ScopedTaskEnvironment();
69 70
71 // Returns a TaskRunner that schedules tasks on the main thread.
72 scoped_refptr<base::SingleThreadTaskRunner> GetMainThreadTaskRunner();
73
70 // Synchronously runs (Thread|Sequenced)TaskRunnerHandle tasks until no 74 // Synchronously runs (Thread|Sequenced)TaskRunnerHandle tasks until no
71 // undelayed (Thread|Sequenced)TaskRunnerHandle or TaskScheduler tasks remain. 75 // undelayed (Thread|Sequenced)TaskRunnerHandle or TaskScheduler tasks remain.
72 void RunUntilIdle(); 76 void RunUntilIdle();
73 77
74 private: 78 private:
75 // Note: |message_loop_| is an implementation detail and will be replaced in 79 // Note: |message_loop_| is an implementation detail and will be replaced in
76 // the future, do NOT rely on the presence of a MessageLoop beyond 80 // the future, do NOT rely on the presence of a MessageLoop beyond
77 // (Thread|Sequenced)TaskRunnerHandle and RunLoop. 81 // (Thread|Sequenced)TaskRunnerHandle and RunLoop.
78 MessageLoop message_loop_; 82 MessageLoop message_loop_;
79 83
80 const TaskScheduler* task_scheduler_ = nullptr; 84 const TaskScheduler* task_scheduler_ = nullptr;
81 85
82 DISALLOW_COPY_AND_ASSIGN(ScopedTaskEnvironment); 86 DISALLOW_COPY_AND_ASSIGN(ScopedTaskEnvironment);
83 }; 87 };
84 88
85 } // namespace test 89 } // namespace test
86 } // namespace base 90 } // namespace base
87 91
88 #endif // BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ 92 #endif // BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_
OLDNEW
« no previous file with comments | « no previous file | base/test/scoped_task_environment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698