no bug - make quit work r=dougt
authorBrad Lassey <blassey@mozilla.com>
Wed, 19 Oct 2011 16:31:31 -0400
changeset 83221 653aa43e96433746fe6846ba8f7321e49f9a3354
parent 83220 9f0b55203981f91d8a220667712f3a93fc0ee953
child 83222 beed650abc13b4d32c02e2a901966a5340881272
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
no bug - make quit work r=dougt
embedding/android/GeckoApp.java
embedding/android/GeckoAppShell.java
other-licenses/android/APKOpen.cpp
toolkit/xre/nsAndroidStartup.cpp
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -401,17 +401,18 @@ abstract public class GeckoApp
                return super.onOptionsItemSelected(item);
         }
     }
 
     private void quit() {
         Log.i(LOG_FILE_NAME, "pleaseKillMe");
         if (surfaceView != null)
             surfaceView.saveLast(true);
-        System.exit(0);
+        GeckoAppShell.nativeQuit();
+        finish();
     }
 
     void handleLocationChange(final int tabId, final String uri) {
         Tab tab = Tabs.getInstance().getTab(tabId);
         if (tab != null)
             tab.updateURL(uri);
 
         if (!Tabs.getInstance().isSelectedTab(tab))
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -105,16 +105,17 @@ public class GeckoAppShell
     static private File sCacheFile = null;
     static private int sFreeSpace = -1;
 
     /* The Android-side API: API methods that Android calls */
 
     // Initialization methods
     public static native void nativeInit();
     public static native void nativeRun(String args);
+    public static native void nativeQuit();
 
     // helper methods
     public static native void setSurfaceView(GeckoSurfaceView sv);
     public static native void putenv(String map);
     public static native void onResume();
     public static native void onLowMemory();
     public static native void callObserver(String observerKey, String topic, String data);
     public static native void removeObserver(String observerKey);
--- a/other-licenses/android/APKOpen.cpp
+++ b/other-licenses/android/APKOpen.cpp
@@ -225,16 +225,17 @@ static name ## _t f_ ## name; \
 extern "C" NS_EXPORT void JNICALL \
 Java_org_mozilla_gecko_GeckoAppShell_ ## name(JNIEnv *jenv, jclass jc, type1 one, type2 two, type3 three) \
 { \
   f_ ## name(jenv, jc, one, two, three); \
 }
 
 SHELL_WRAPPER0(nativeInit)
 SHELL_WRAPPER1(nativeRun, jstring)
+SHELL_WRAPPER0(nativeQuit)
 SHELL_WRAPPER1(notifyGeckoOfEvent, jobject)
 SHELL_WRAPPER0(processNextNativeEvent)
 SHELL_WRAPPER1(setSurfaceView, jobject)
 SHELL_WRAPPER0(onResume)
 SHELL_WRAPPER0(onLowMemory)
 SHELL_WRAPPER3(callObserver, jstring, jstring, jstring)
 SHELL_WRAPPER1(removeObserver, jstring)
 SHELL_WRAPPER1(onChangeNetworkLinkStatus, jstring)
@@ -630,16 +631,17 @@ loadLibs(const char *apkName)
 #endif
 
   if (!xul_handle)
     __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libxul!");
 
 #define GETFUNC(name) f_ ## name = (name ## _t) __wrap_dlsym(xul_handle, "Java_org_mozilla_gecko_GeckoAppShell_" #name)
   GETFUNC(nativeInit);
   GETFUNC(nativeRun);
+  GETFUNC(nativeQuit);
   GETFUNC(notifyGeckoOfEvent);
   GETFUNC(processNextNativeEvent);
   GETFUNC(setSurfaceView);
   GETFUNC(onResume);
   GETFUNC(onLowMemory);
   GETFUNC(callObserver);
   GETFUNC(removeObserver);
   GETFUNC(onChangeNetworkLinkStatus);
--- a/toolkit/xre/nsAndroidStartup.cpp
+++ b/toolkit/xre/nsAndroidStartup.cpp
@@ -49,16 +49,18 @@
 
 #include "nsTArray.h"
 #include "nsString.h"
 #include "nsILocalFile.h"
 #include "nsAppRunner.h"
 #include "AndroidBridge.h"
 #include "APKOpen.h"
 #include "nsExceptionHandler.h"
+#include "nsIAppStartup.h"
+#include "nsToolkitCompsCID.h"
 
 #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, MOZ_APP_NAME, args)
 
 #define _STR(s) # s
 #define STR(s) _STR(s)
 
 struct AutoAttachJavaThread {
     AutoAttachJavaThread() {
@@ -163,8 +165,16 @@ Java_org_mozilla_gecko_GeckoAppShell_nat
     int len = jenv->GetStringLength(jargs);
     wargs.SetLength(jenv->GetStringLength(jargs));
     jenv->GetStringRegion(jargs, 0, len, wargs.BeginWriting());
     char *args = ToNewUTF8String(wargs);
 
     GeckoStart(args);
 }
 
+extern "C" NS_EXPORT void JNICALL
+Java_org_mozilla_gecko_GeckoAppShell_nativeQuit(JNIEnv*, jclass)
+{
+    nsCOMPtr<nsIAppStartup> appStartup =
+        do_GetService(NS_APPSTARTUP_CONTRACTID);
+    if (appStartup)
+        appStartup->Quit(nsIAppStartup::eAttemptQuit);
+}