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

Unified Diff: base/message_loop.h

Issue 10479018: Add base::RunLoop and update ui_test_utils to use it to reduce flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more test fixes Created 8 years, 6 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 | « no previous file | base/message_loop.cc » ('j') | chrome/test/base/ui_test_utils.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop.h
diff --git a/base/message_loop.h b/base/message_loop.h
index d78b58addc2019ad46b61e79adf8c918f432a9dd..ccd668fc9172b38a186f518b332655c3e285707a 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -224,23 +224,47 @@ class BASE_EXPORT MessageLoop : public base::MessagePump::Delegate {
// Return as soon as all items that can be run are taken care of.
void RunAllPending();
- // Signals the Run method to return after it is done processing all pending
- // messages. This method may only be called on the same thread that called
- // Run, and Run must still be on the call stack.
+ // TODO(jbates) remove this. crbug.com/131220. See QuitWhenIdle().
+ void Quit() { QuitWhenIdle(); }
+
+ // Signals the Run method to return when it becomes idle. It will continue to
+ // process pending messages and future messages as long as they are enqueued.
+ // Warning: if the MessageLoop remains busy, it may never quit. Only use this
+ // Quit method when looping procedures (such as web pages) have been shut
+ // down.
//
- // Use QuitClosure if you need to Quit another thread's MessageLoop, but note
- // that doing so is fairly dangerous if the target thread makes nested calls
- // to MessageLoop::Run. The problem being that you won't know which nested
- // run loop you are quitting, so be careful!
- void Quit();
+ // This method may only be called on the same thread that called Run, and Run
+ // must still be on the call stack.
+ //
+ // Use Quit*Closure variants if you need to Quit another thread's MessageLoop,
+ // but note that doing so is fairly dangerous if the target thread makes
+ // nested calls to MessageLoop::Run. The problem being that you won't know
+ // which nested run loop you are quitting, so be careful!
+ void QuitWhenIdle();
// This method is a variant of Quit, that does not wait for pending messages
// to be processed before returning from Run.
void QuitNow();
- // Invokes Quit on the current MessageLoop when run. Useful to schedule an
- // arbitrary MessageLoop to Quit.
- static base::Closure QuitClosure();
+ // This method is a variant of Quit, that only waits for the currently pending
+ // messages to complete. Any new messages after this call will not be
+ // processed and will remain enqueued on the MessageLoop.
+ void QuitAfterPending();
jar (doing other things) 2012/06/08 01:05:37 nit: I think this is now too terse. I read it as:
jbates 2012/06/13 22:11:20 Removed it since it wasn't adding more than QuitNo
+
+ // TODO(jbates) remove this. crbug.com/131220. See QuitWhenIdleClosure().
+ static base::Closure QuitClosure() { return QuitWhenIdleClosure(); }
+
+ // Invokes QuitWhenIdle on the current MessageLoop when run. Useful to
jar (doing other things) 2012/06/08 01:05:37 nit: I don't think "current MessageLoop" should be
jbates 2012/06/13 22:11:20 Done.
+ // schedule an arbitrary MessageLoop to QuitWhenIdle.
+ static base::Closure QuitWhenIdleClosure();
+
+ // Invokes QuitNow on the current MessageLoop when run. Useful to schedule an
+ // arbitrary MessageLoop to QuitNow.
+ static base::Closure QuitNowClosure();
+
+ // Invokes QuitAfterPending on the current MessageLoop when run. Useful to
+ // schedule an arbitrary MessageLoop to QuitAfterPending.
+ static base::Closure QuitAfterPendingClosure();
// Returns the type passed to the constructor.
Type type() const { return type_; }
« no previous file with comments | « no previous file | base/message_loop.cc » ('j') | chrome/test/base/ui_test_utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698