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

Side by Side Diff: content/public/test/test_utils.h

Issue 2564943002: Reland "Add thread checking to RunLoop, deprecate MessageLoopRunner. (patchset #4 id:20002 of https… (Closed)
Patch Set: Created 4 years 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 | « content/public/test/test_launcher.h ('k') | content/public/test/test_utils.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 (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 #ifndef CONTENT_PUBLIC_TEST_TEST_UTILS_H_ 5 #ifndef CONTENT_PUBLIC_TEST_TEST_UTILS_H_
6 #define CONTENT_PUBLIC_TEST_TEST_UTILS_H_ 6 #define CONTENT_PUBLIC_TEST_TEST_UTILS_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // thread |thread_id| have been processed. Can only be called from the UI 55 // thread |thread_id| have been processed. Can only be called from the UI
56 // thread. 56 // thread.
57 void RunAllPendingInMessageLoop(BrowserThread::ID thread_id); 57 void RunAllPendingInMessageLoop(BrowserThread::ID thread_id);
58 58
59 // Runs until both the blocking pool and the current message loop are empty 59 // Runs until both the blocking pool and the current message loop are empty
60 // (have no more scheduled tasks) and no tasks are running. 60 // (have no more scheduled tasks) and no tasks are running.
61 void RunAllBlockingPoolTasksUntilIdle(); 61 void RunAllBlockingPoolTasksUntilIdle();
62 62
63 // Get task to quit the given RunLoop. It allows a few generations of pending 63 // Get task to quit the given RunLoop. It allows a few generations of pending
64 // tasks to run as opposed to run_loop->QuitClosure(). 64 // tasks to run as opposed to run_loop->QuitClosure().
65 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop); 65 base::Closure GetDeferredQuitTaskForRunLoop(base::RunLoop* run_loop);
66 66
67 // Executes the specified JavaScript in the specified frame, and runs a nested 67 // Executes the specified JavaScript in the specified frame, and runs a nested
68 // MessageLoop. When the result is available, it is returned. 68 // MessageLoop. When the result is available, it is returned.
69 // This should not be used; the use of the ExecuteScript functions in 69 // This should not be used; the use of the ExecuteScript functions in
70 // browser_test_utils is preferable. 70 // browser_test_utils is preferable.
71 std::unique_ptr<base::Value> ExecuteScriptAndGetValue( 71 std::unique_ptr<base::Value> ExecuteScriptAndGetValue(
72 RenderFrameHost* render_frame_host, 72 RenderFrameHost* render_frame_host,
73 const std::string& script); 73 const std::string& script);
74 74
75 // Returns true if all sites are isolated. Typically used to bail from a test 75 // Returns true if all sites are isolated. Typically used to bail from a test
76 // that is incompatible with --site-per-process. 76 // that is incompatible with --site-per-process.
77 bool AreAllSitesIsolatedForTesting(); 77 bool AreAllSitesIsolatedForTesting();
78 78
79 // Appends --site-per-process to the command line, enabling tests to exercise 79 // Appends --site-per-process to the command line, enabling tests to exercise
80 // site isolation and cross-process iframes. This must be called early in 80 // site isolation and cross-process iframes. This must be called early in
81 // the test; the flag will be read on the first real navigation. 81 // the test; the flag will be read on the first real navigation.
82 void IsolateAllSitesForTesting(base::CommandLine* command_line); 82 void IsolateAllSitesForTesting(base::CommandLine* command_line);
83 83
84 #if defined(OS_ANDROID) 84 #if defined(OS_ANDROID)
85 // Registers content/browser JNI bindings necessary for some types of tests. 85 // Registers content/browser JNI bindings necessary for some types of tests.
86 bool RegisterJniForTesting(JNIEnv* env); 86 bool RegisterJniForTesting(JNIEnv* env);
87 #endif 87 #endif
88 88
89 // Helper class to Run and Quit the message loop. Run and Quit can only happen 89 // Helper class to Run and Quit the message loop. Run and Quit can only happen
90 // once per instance. Make a new instance for each use. Calling Quit after Run 90 // once per instance. Make a new instance for each use. Calling Quit after Run
91 // has returned is safe and has no effect. 91 // has returned is safe and has no effect.
92 // Note that by default Quit does not quit immediately. If that is not what you 92 // Note that by default Quit does not quit immediately. If that is not what you
93 // really need, pass QuitMode::IMMEDIATE in the constructor. 93 // really need, pass QuitMode::IMMEDIATE in the constructor.
94 //
95 // DEPRECATED. Consider using base::RunLoop, in most cases MessageLoopRunner is
96 // not needed. If you need to defer quitting the loop, use
97 // GetDeferredQuitTaskForRunLoop directly.
98 // If you found a case where base::RunLoop is inconvenient or can not be used at
99 // all, please post details in a comment on https://crbug.com/668707.
94 class MessageLoopRunner : public base::RefCounted<MessageLoopRunner> { 100 class MessageLoopRunner : public base::RefCounted<MessageLoopRunner> {
95 public: 101 public:
96 enum class QuitMode { 102 enum class QuitMode {
97 // Message loop stops after finishing the current task. 103 // Message loop stops after finishing the current task.
98 IMMEDIATE, 104 IMMEDIATE,
99 105
100 // Several generations of posted tasks are executed before stopping. 106 // Several generations of posted tasks are executed before stopping.
101 DEFERRED, 107 DEFERRED,
102 }; 108 };
103 109
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 void WebContentsDestroyed() override; 301 void WebContentsDestroyed() override;
296 302
297 scoped_refptr<MessageLoopRunner> message_loop_runner_; 303 scoped_refptr<MessageLoopRunner> message_loop_runner_;
298 304
299 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); 305 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher);
300 }; 306 };
301 307
302 } // namespace content 308 } // namespace content
303 309
304 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ 310 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « content/public/test/test_launcher.h ('k') | content/public/test/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698