Bug 860879 - Make GeckoAppShell.processNextNativeEvent waitable; r=blassey
authorJim Chen <nchen@mozilla.com>
Thu, 09 May 2013 21:48:00 -0400
changeset 131468 4b3b08aeba3de1307814c6df61f8dc95a42d897b
parent 131467 3c189f66a528ba6edd8e01dd4a6c018557205818
child 131469 2e1981be9749ddf738f1558b506271dc877746c4
push idunknown
push userunknown
push dateunknown
reviewersblassey
bugs860879
milestone23.0a1
Bug 860879 - Make GeckoAppShell.processNextNativeEvent waitable; r=blassey
mobile/android/base/ActivityHandlerHelper.java
mobile/android/base/GeckoAppShell.java
mobile/android/base/PromptService.java
mozglue/android/jni-stubs.inc
widget/android/AndroidJNI.cpp
--- a/mobile/android/base/ActivityHandlerHelper.java
+++ b/mobile/android/base/ActivityHandlerHelper.java
@@ -207,17 +207,17 @@ public class ActivityHandlerHelper {
             Log.e(LOGTAG, "We should not get an intent with another action!");
             return "";
         }
 
         String filePickerResult = "";
 
         try {
             while (null == (filePickerResult = mFilePickerResult.poll(1, TimeUnit.MILLISECONDS))) {
-                GeckoAppShell.processNextNativeEvent();
+                GeckoAppShell.processNextNativeEvent(false);
             }
         } catch (InterruptedException e) {
             Log.e(LOGTAG, "showing file picker failed: ",  e);
         }
 
         return filePickerResult;
     }
 
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -207,17 +207,17 @@ public class GeckoAppShell
     }
 
     private static native void reportJavaCrash(String stackTrace);
 
     public static void notifyUriVisited(String uri) {
         sendEventToGecko(GeckoEvent.createVisitedEvent(uri));
     }
 
-    public static native void processNextNativeEvent();
+    public static native void processNextNativeEvent(boolean mayWait);
 
     public static native void notifyBatteryChange(double aLevel, boolean aCharging, double aRemainingTime);
 
     public static native void scheduleComposite();
 
     // Resuming the compositor is a synchronous request, so be
     // careful of possible deadlock. Resuming the compositor will also cause
     // a composition, so there is no need to schedule a composition after
--- a/mobile/android/base/PromptService.java
+++ b/mobile/android/base/PromptService.java
@@ -284,17 +284,17 @@ public class PromptService implements On
     // GeckoEventResponder implementation
     @Override
     public String getResponse() {
         // we only handle one kind of message in handleMessage, and this is the
         // response we provide for that message
         String result = null;
         try {
             while (null == (result = mPromptQueue.poll(1, TimeUnit.MILLISECONDS))) {
-                GeckoAppShell.processNextNativeEvent();
+                GeckoAppShell.processNextNativeEvent(false);
             }
         } catch (InterruptedException e) {
         }
         return result != null ? result : "";
     }
 
     private View applyInputStyle(View view) {
         view.setPadding(mInputPaddingSize, 0, mInputPaddingSize, 0);
--- a/mozglue/android/jni-stubs.inc
+++ b/mozglue/android/jni-stubs.inc
@@ -186,26 +186,26 @@ Java_org_mozilla_gecko_GeckoAppShell_rep
 #endif
 
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash", &f_Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash);
 #endif
 
 #ifdef JNI_STUBS
 
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent_t)(JNIEnv *, jclass);
+typedef void (*Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent_t)(JNIEnv *, jclass, jboolean);
 static Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent_t f_Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent;
 extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(JNIEnv * arg0, jclass arg1) {
+Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(JNIEnv * arg0, jclass arg1, jboolean arg2) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
-     f_Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(arg0, arg1);
+     f_Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(arg0, arg1, arg2);
 }
 #endif
 
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent", &f_Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent);
 #endif
 
 #ifdef JNI_STUBS
--- a/widget/android/AndroidJNI.cpp
+++ b/widget/android/AndroidJNI.cpp
@@ -63,21 +63,21 @@ NS_EXPORT void JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(JNIEnv *jenv, jclass jc, jobject event)
 {
     // poke the appshell
     if (nsAppShell::gAppShell)
         nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeFromJavaObject(jenv, event));
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(JNIEnv *jenv, jclass)
+Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(JNIEnv *jenv, jclass, jboolean mayWait)
 {
     // poke the appshell
     if (nsAppShell::gAppShell)
-        nsAppShell::gAppShell->ProcessNextNativeEvent(false);
+        nsAppShell::gAppShell->ProcessNextNativeEvent(mayWait != JNI_FALSE);
 }
 
 NS_EXPORT void JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_setLayerClient(JNIEnv *jenv, jclass, jobject obj)
 {
     AndroidBridge::Bridge()->SetLayerClient(jenv, obj);
 }