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

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

Issue 2836963002: Allow ScopedTaskEnvironment to pump UI or IO messages on the main thread. (Closed)
Patch Set: self-review Created 3 years, 8 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 10
(...skipping 14 matching lines...) Expand all
25 // RunLoop::Run(UntilIdle) is called on the thread where the 25 // RunLoop::Run(UntilIdle) is called on the thread where the
26 // ScopedTaskEnvironment lives. 26 // ScopedTaskEnvironment lives.
27 // 27 //
28 // Tasks posted through base/task_scheduler/post_task.h run on dedicated threads 28 // Tasks posted through base/task_scheduler/post_task.h run on dedicated threads
29 // as they are posted. 29 // as they are posted.
30 // 30 //
31 // Design and future improvements documented in 31 // Design and future improvements documented in
32 // https://docs.google.com/document/d/1QabRo8c7D9LsYY3cEcaPQbOCLo8Tu-6VLykYXyl3P kk/edit 32 // https://docs.google.com/document/d/1QabRo8c7D9LsYY3cEcaPQbOCLo8Tu-6VLykYXyl3P kk/edit
33 class ScopedTaskEnvironment { 33 class ScopedTaskEnvironment {
34 public: 34 public:
35 ScopedTaskEnvironment(); 35 enum class MainThreadType {
36 // The main thread pumps UI messages.
37 UI,
38 // The main thread pumps asynchronous IO messages.
39 IO,
40 };
41
42 ScopedTaskEnvironment(MainThreadType main_thread_type = MainThreadType::UI);
robliao 2017/04/24 22:42:31 The default message loop was used before (does not
36 43
37 // Runs pending (Thread|Sequenced)TaskRunnerHandle tasks and pending 44 // Runs pending (Thread|Sequenced)TaskRunnerHandle tasks and pending
38 // BLOCK_SHUTDOWN TaskScheduler tasks. Then, unregisters the TaskScheduler and 45 // BLOCK_SHUTDOWN TaskScheduler tasks. Then, unregisters the TaskScheduler and
39 // the (Thread|Sequenced)TaskRunnerHandle. 46 // the (Thread|Sequenced)TaskRunnerHandle.
40 ~ScopedTaskEnvironment(); 47 ~ScopedTaskEnvironment();
41 48
42 private: 49 private:
43 // Note: |message_loop_| is an implementation detail and will be replaced in 50 // Note: |message_loop_| is an implementation detail and will be replaced in
44 // the future, do NOT rely on the presence of a MessageLoop beyond 51 // the future, do NOT rely on the presence of a MessageLoop beyond
45 // (Thread|Sequenced)TaskRunnerHandle and RunLoop. 52 // (Thread|Sequenced)TaskRunnerHandle and RunLoop.
46 MessageLoop message_loop_; 53 MessageLoop message_loop_;
47 54
48 const TaskScheduler* task_scheduler_ = nullptr; 55 const TaskScheduler* task_scheduler_ = nullptr;
49 56
50 DISALLOW_COPY_AND_ASSIGN(ScopedTaskEnvironment); 57 DISALLOW_COPY_AND_ASSIGN(ScopedTaskEnvironment);
51 }; 58 };
52 59
53 } // namespace test 60 } // namespace test
54 } // namespace base 61 } // namespace base
55 62
56 #endif // BASE_TEST_SCOPED_ASYNC_TASK_SCHEDULER_H_ 63 #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