aboutsummaryrefslogtreecommitdiff
path: root/base/message_loop/message_pump_android.cc
diff options
context:
space:
mode:
authorLuis Hector Chavez <lhchavez@google.com>2017-07-26 17:38:05 +0000
committerLuis Hector Chavez <lhchavez@google.com>2017-07-26 17:38:05 +0000
commit21a249e4d9cb0b2ec6f0ff84ed5f7939ea67ac52 (patch)
treed380c2689495d31fd250cf8f1d0ceebbdd4cf250 /base/message_loop/message_pump_android.cc
parent8ac9103e05b66812c25348943383f9365d1ce3e0 (diff)
downloadlibmojo-21a249e4d9cb0b2ec6f0ff84ed5f7939ea67ac52.tar.gz
Revert "libmojo: Uprev the library to r456626 from Chromium"
This reverts commit 8ac9103e05b66812c25348943383f9365d1ce3e0. Reason for revert: Broke the mac_sdk Exempt-From-Owner-Approval: Fixing mac_sdk Change-Id: I0b74d1abaa66933a93fd6f82ff018e8948c1204e
Diffstat (limited to 'base/message_loop/message_pump_android.cc')
-rw-r--r--base/message_loop/message_pump_android.cc56
1 files changed, 12 insertions, 44 deletions
diff --git a/base/message_loop/message_pump_android.cc b/base/message_loop/message_pump_android.cc
index bedb205..a0eee12 100644
--- a/base/message_loop/message_pump_android.cc
+++ b/base/message_loop/message_pump_android.cc
@@ -6,17 +6,14 @@
#include <jni.h>
-#include "base/android/java_message_handler_factory.h"
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/time/time.h"
#include "jni/SystemMessageHandler_jni.h"
-using base::android::JavaParamRef;
using base::android::ScopedJavaLocalRef;
// ----------------------------------------------------------------------------
@@ -27,14 +24,10 @@ using base::android::ScopedJavaLocalRef;
static void DoRunLoopOnce(JNIEnv* env,
const JavaParamRef<jobject>& obj,
jlong native_delegate,
- jlong native_message_pump,
jlong delayed_scheduled_time_ticks) {
base::MessagePump::Delegate* delegate =
reinterpret_cast<base::MessagePump::Delegate*>(native_delegate);
DCHECK(delegate);
- base::MessagePumpForUI* pump =
- reinterpret_cast<base::MessagePumpForUI*>(native_message_pump);
- DCHECK(pump);
// This is based on MessagePumpForUI::DoRunLoop() from desktop.
// Note however that our system queue is handled in the java side.
// In desktop we inspect and process a single system message and then
@@ -42,11 +35,6 @@ static void DoRunLoopOnce(JNIEnv* env,
// On Android, the java message queue may contain messages for other handlers
// that will be processed before calling here again.
bool did_work = delegate->DoWork();
- if (pump->ShouldAbort()) {
- // There is a pending JNI exception, return to Java so that the exception is
- // thrown correctly.
- return;
- }
// In the java side, |SystemMessageHandler| keeps a single "delayed" message.
// It's an expensive operation to |removeMessage| there, so this is optimized
@@ -72,11 +60,6 @@ static void DoRunLoopOnce(JNIEnv* env,
// avoid comparisons with TimeDelta / Now() (expensive).
base::TimeTicks next_delayed_work_time;
did_work |= delegate->DoDelayedWork(&next_delayed_work_time);
- if (pump->ShouldAbort()) {
- // There is a pending JNI exception, return to Java so that the exception is
- // thrown correctly
- return;
- }
if (!next_delayed_work_time.is_null()) {
// Schedule a new message if there's nothing already scheduled or there's a
@@ -98,16 +81,13 @@ static void DoRunLoopOnce(JNIEnv* env,
return;
delegate->DoIdleWork();
- // Note that we do not check whether we should abort here since we are
- // returning to the JVM anyway. If, in the future, we add any more code after
- // the call to DoIdleWork() here, we should add an abort-check and return
- // immediately if the check passes.
}
namespace base {
MessagePumpForUI::MessagePumpForUI()
- : run_loop_(nullptr), should_abort_(false) {}
+ : run_loop_(NULL) {
+}
MessagePumpForUI::~MessagePumpForUI() {
}
@@ -117,7 +97,7 @@ void MessagePumpForUI::Run(Delegate* delegate) {
" test_stub_android.h";
}
-JNIEnv* MessagePumpForUI::StartInternal() {
+void MessagePumpForUI::Start(Delegate* delegate) {
run_loop_ = new 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).
@@ -128,23 +108,10 @@ JNIEnv* MessagePumpForUI::StartInternal() {
JNIEnv* env = base::android::AttachCurrentThread();
DCHECK(env);
- return env;
-}
-
-void MessagePumpForUI::Start(Delegate* delegate) {
- JNIEnv* env = StartInternal();
- system_message_handler_obj_.Reset(Java_SystemMessageHandler_create(
- env, reinterpret_cast<intptr_t>(delegate),
- reinterpret_cast<intptr_t>(this)));
-}
-void MessagePumpForUI::StartForUnitTest(
- Delegate* delegate,
- base::android::JavaMessageHandlerFactory* factory,
- WaitableEvent* test_done_event) {
- JNIEnv* env = StartInternal();
system_message_handler_obj_.Reset(
- factory->CreateMessageHandler(env, delegate, this, test_done_event));
+ Java_SystemMessageHandler_create(
+ env, reinterpret_cast<intptr_t>(delegate)));
}
void MessagePumpForUI::Quit() {
@@ -152,8 +119,8 @@ void MessagePumpForUI::Quit() {
JNIEnv* env = base::android::AttachCurrentThread();
DCHECK(env);
- Java_SystemMessageHandler_removeAllPendingMessages(
- env, system_message_handler_obj_);
+ Java_SystemMessageHandler_removeAllPendingMessages(env,
+ system_message_handler_obj_.obj());
system_message_handler_obj_.Reset();
}
@@ -170,7 +137,8 @@ void MessagePumpForUI::ScheduleWork() {
JNIEnv* env = base::android::AttachCurrentThread();
DCHECK(env);
- Java_SystemMessageHandler_scheduleWork(env, system_message_handler_obj_);
+ Java_SystemMessageHandler_scheduleWork(env,
+ system_message_handler_obj_.obj());
}
void MessagePumpForUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time) {
@@ -183,9 +151,9 @@ void MessagePumpForUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time) {
(delayed_work_time - TimeTicks::Now()).InMillisecondsRoundedUp();
// Note that we're truncating to milliseconds as required by the java side,
// even though delayed_work_time is microseconds resolution.
- Java_SystemMessageHandler_scheduleDelayedWork(
- env, system_message_handler_obj_, delayed_work_time.ToInternalValue(),
- millis);
+ Java_SystemMessageHandler_scheduleDelayedWork(env,
+ system_message_handler_obj_.obj(),
+ delayed_work_time.ToInternalValue(), millis);
}
// static