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

Unified Diff: content/test/test_utils.cc

Issue 10825085: Move RunAllPendingInMessageLoop from ui_test_utils.h to test_utils.h, so that it can be reused by c… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/shell_content_client.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/test_utils.cc
===================================================================
--- content/test/test_utils.cc (revision 149002)
+++ content/test/test_utils.cc (working copy)
@@ -34,8 +34,16 @@
}
}
+void RunAllPendingMessageAndSendQuit(BrowserThread::ID thread_id,
+ const base::Closure& quit_task) {
+ MessageLoop::current()->PostTask(FROM_HERE,
+ MessageLoop::QuitWhenIdleClosure());
+ RunMessageLoop();
scottmg 2012/07/30 20:23:26 Replace 39-41 with content::RunAllPendingInMessage
jam 2012/07/30 20:34:21 Done.
+ BrowserThread::PostTask(thread_id, FROM_HERE, quit_task);
}
+} // namespace
+
namespace content {
void RunMessageLoop() {
@@ -57,6 +65,30 @@
delegate->PostRunMessageLoop();
}
+void RunAllPendingInMessageLoop() {
+ MessageLoop::current()->PostTask(FROM_HERE,
+ MessageLoop::QuitWhenIdleClosure());
+ RunMessageLoop();
+}
+
+void RunAllPendingInMessageLoop(BrowserThread::ID thread_id) {
+ if (BrowserThread::CurrentlyOn(thread_id)) {
+ RunAllPendingInMessageLoop();
+ return;
+ }
+ BrowserThread::ID current_thread_id;
+ if (!BrowserThread::GetCurrentThreadIdentifier(&current_thread_id)) {
+ NOTREACHED();
+ return;
+ }
+
+ base::RunLoop run_loop;
+ BrowserThread::PostTask(thread_id, FROM_HERE,
+ base::Bind(&RunAllPendingMessageAndSendQuit, current_thread_id,
+ run_loop.QuitClosure()));
+ RunThisRunLoop(&run_loop);
+}
+
base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop) {
return base::Bind(&DeferredQuitRunLoop, run_loop->QuitClosure(),
kNumQuitDeferrals);
« no previous file with comments | « content/shell/shell_content_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698