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(¤t_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); |