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

Unified Diff: base/message_pump_android.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: phajdan feedback 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 | « base/message_pump_android.h ('k') | base/message_pump_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_android.cc
diff --git a/base/message_pump_android.cc b/base/message_pump_android.cc
index 2daf98db3157fa8ac9aed43ce34052745119836b..25f7fb78473f82775de6304e599fd1c4cfbe07c6 100644
--- a/base/message_pump_android.cc
+++ b/base/message_pump_android.cc
@@ -10,6 +10,7 @@
#include "base/android/scoped_java_ref.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/run_loop.h"
#include "jni/system_message_handler_jni.h"
using base::android::ScopedJavaLocalRef;
@@ -61,7 +62,7 @@ static jboolean DoRunLoopOnce(JNIEnv* env, jobject obj, jint native_delegate) {
namespace base {
MessagePumpForUI::MessagePumpForUI()
- : state_(NULL) {
+ : run_loop_(NULL) {
}
MessagePumpForUI::~MessagePumpForUI() {
@@ -73,7 +74,11 @@ void MessagePumpForUI::Run(Delegate* delegate) {
}
void MessagePumpForUI::Start(Delegate* delegate) {
- state_ = new MessageLoop::AutoRunState(MessageLoop::current());
+ run_loop_ = new base::RunLoop();
+ // Since the RunLoop was just created above, BeforeRun should be guaranteed to
+ // return true (it only returns false if the RunLoop has been Quit already).
+ if (!run_loop_->BeforeRun())
+ NOTREACHED();
DCHECK(g_system_message_handler_obj.Get().is_null());
@@ -94,9 +99,10 @@ void MessagePumpForUI::Quit() {
g_system_message_handler_obj.Get().Reset();
}
- if (state_) {
- delete state_;
- state_ = NULL;
+ if (run_loop_) {
+ run_loop_->AfterRun();
+ delete run_loop_;
+ run_loop_ = NULL;
}
}
« no previous file with comments | « base/message_pump_android.h ('k') | base/message_pump_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698