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

Unified Diff: base/message_loop.cc

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
Index: base/message_loop.cc
diff --git a/base/message_loop.cc b/base/message_loop.cc
index a207659a4a922203a2e3850bbcdde4b1425dd21d..7a6e0921cb09d1b91cb845b24a62a22ea9caf610 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -313,7 +313,7 @@ void MessageLoop::RunAllPending() {
RunHandler();
}
-void MessageLoop::Quit() {
+void MessageLoop::QuitWhenIdle() {
DCHECK_EQ(this, current());
if (state_) {
state_->quit_received = true;
@@ -331,13 +331,40 @@ void MessageLoop::QuitNow() {
}
}
-static void QuitCurrent() {
- MessageLoop::current()->Quit();
+void MessageLoop::QuitAfterPending() {
+ DCHECK_EQ(this, current());
+ if (state_) {
+ PostTask(FROM_HERE, MessageLoop::QuitNowClosure());
+ } else {
+ NOTREACHED() << "Must be inside Run to call Quit";
+ }
+}
+
+static void QuitWhenIdleCurrent() {
+ MessageLoop::current()->QuitWhenIdle();
+}
+
+static void QuitNowCurrent() {
+ MessageLoop::current()->QuitNow();
+}
+
+static void QuitAfterPendingCurrent() {
+ MessageLoop::current()->QuitAfterPending();
+}
+
+// static
+base::Closure MessageLoop::QuitWhenIdleClosure() {
+ return base::Bind(&QuitWhenIdleCurrent);
+}
+
+// static
+base::Closure MessageLoop::QuitNowClosure() {
+ return base::Bind(&QuitNowCurrent);
}
// static
-base::Closure MessageLoop::QuitClosure() {
- return base::Bind(&QuitCurrent);
+base::Closure MessageLoop::QuitAfterPendingClosure() {
+ return base::Bind(&QuitAfterPendingCurrent);
}
void MessageLoop::SetNestableTasksAllowed(bool allowed) {

Powered by Google App Engine
This is Rietveld 408576698