Chromium Code Reviews| Index: content/public/test/test_utils.h |
| diff --git a/content/public/test/test_utils.h b/content/public/test/test_utils.h |
| index d479eb5afe1a0636b1a8be1db6e412c6c37989e7..b063cf79a56dfccbe76e588627f161c6b6aa5bd6 100644 |
| --- a/content/public/test/test_utils.h |
| +++ b/content/public/test/test_utils.h |
| @@ -89,9 +89,16 @@ bool RegisterJniForTesting(JNIEnv* env); |
| // Helper class to Run and Quit the message loop. Run and Quit can only happen |
| // once per instance. Make a new instance for each use. Calling Quit after Run |
| // has returned is safe and has no effect. |
| +// Note that by default Quit does not quit immediately. If that is not what you |
| +// really need, pass QuitMode::IMMEDIATE in the constructor. |
| class MessageLoopRunner : public base::RefCounted<MessageLoopRunner> { |
| public: |
| - MessageLoopRunner(); |
| + enum class QuitMode { |
| + IMMEDIATE, // Message loop stops after finishing the current task. |
| + LOOSE, // Several generations of posted tasks are executed before stopping. |
| + }; |
| + |
| + MessageLoopRunner(QuitMode mode = QuitMode::LOOSE); |
|
nasko
2016/11/23 17:48:29
Instead of making the quit type be captured for th
Alexander Semashko
2016/11/23 18:38:08
I thought the current way would be clearer; also t
nasko
2016/11/24 00:00:43
lukasza@ pointed out a different argument in favor
Alexander Semashko
2016/11/24 10:31:42
Too loose name could be an additional warning for
|
| // Run the current MessageLoop unless the quit closure |
| // has already been called. |
| @@ -113,6 +120,8 @@ class MessageLoopRunner : public base::RefCounted<MessageLoopRunner> { |
| friend class base::RefCounted<MessageLoopRunner>; |
| ~MessageLoopRunner(); |
| + QuitMode quit_mode_; |
| + |
| // True when the message loop is running. |
| bool loop_running_; |