Bug 630595 - Followup. Do not need a dash before the option. Removing unused memory watcher. r=blassey, a=blocking-fennec
authorDoug Turner <dougt@dougt.org>
Wed, 02 Feb 2011 01:00:34 -0800
changeset 61775 07833d6a068539742a7ebafde72647cb86fcee1e
parent 61774 1bbbe11e29681528d1dedfd2b32dafc92f34bf1a
child 61776 dc8abaadc629a1f1cc8aad985026e8673cf3557b
push idunknown
push userunknown
push dateunknown
reviewersblassey, blocking-fennec
bugs630595
milestone2.0b11pre
Bug 630595 - Followup. Do not need a dash before the option. Removing unused memory watcher. r=blassey, a=blocking-fennec
dom/ipc/ContentParent.cpp
embedding/android/GeckoApp.java
embedding/android/GeckoAppShell.java
embedding/android/Makefile.in
other-licenses/android/APKOpen.cpp
widget/src/android/AndroidJNI.cpp
xpcom/base/nsIMemory.idl
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -362,30 +362,17 @@ ContentParent::Observe(nsISupports* aSub
         NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
     }
 
     if (!mIsAlive || !mSubprocess)
         return NS_OK;
 
     // listening for memory pressure event
     if (!strcmp(aTopic, "memory-pressure")) {
-      NS_ConvertUTF16toUTF8 dataStr(aData);
-      const char *deathPending = dataStr.get();
-
-      if (!strcmp(deathPending, "oom-kill")) {
-#ifdef MOZ_CRASHREPORTER
-          nsCOMPtr<nsICrashReporter> cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1");
-          if (cr) {
-              cr->AnnotateCrashReport(NS_LITERAL_CSTRING("oom"), NS_LITERAL_CSTRING("true"));
-          }
-#endif
-          KillProcess(OtherProcess(), 0, false);
-      }
-      else
-        SendFlushMemory(nsDependentString(aData));
+      SendFlushMemory(nsDependentString(aData));
     }
     // listening for remotePrefs...
     else if (!strcmp(aTopic, "nsPref:changed")) {
         // We know prefs are ASCII here.
         NS_LossyConvertUTF16toASCII strData(aData);
 
         nsCOMPtr<nsIPrefServiceInternal> prefService =
           do_GetService("@mozilla.org/preferences-service;1");
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -65,17 +65,16 @@ abstract public class GeckoApp
     public static final String ACTION_ALERT_CLICK = "org.mozilla.gecko.ACTION_ALERT_CLICK";
     public static final String ACTION_ALERT_CLEAR = "org.mozilla.gecko.ACTION_ALERT_CLEAR";
 
     public static FrameLayout mainLayout;
     public static GeckoSurfaceView surfaceView;
     public static GeckoApp mAppContext;
     public static boolean mFullscreen = false;
     static Thread mLibLoadThread = null;
-    private static MemoryWatcher mMemoryWatcher = null;
 
     enum LaunchState {PreLaunch, Launching, WaitButton,
                       Launched, GeckoRunning, GeckoExiting};
     private static LaunchState sLaunchState = LaunchState.PreLaunch;
 
     
     static boolean checkLaunchState(LaunchState checkState) {
         synchronized(sLaunchState) {
@@ -209,18 +208,16 @@ abstract public class GeckoApp
              new File(getApplication().getPackageResourcePath()).lastModified()
              >= libxulFile.lastModified()))
             surfaceView.mSplashStatusMsg =
                 getResources().getString(R.string.splash_screen_installing);
         else
             surfaceView.mSplashStatusMsg =
                 getResources().getString(R.string.splash_screen_label);
         mLibLoadThread.start();
-
-        mMemoryWatcher = new MemoryWatcher(this);
     }
 
     @Override
     protected void onNewIntent(Intent intent) {
         if (checkLaunchState(LaunchState.GeckoExiting)) {
             // We're exiting and shouldn't try to do anything else just incase
             // we're hung for some reason we'll force the process to exit
             System.exit(0);
@@ -270,36 +267,32 @@ abstract public class GeckoApp
         // has come to the foreground yet; for Gecko, we may want to
         // stop repainting, for example.
 
         // Whatever we do here should be fast, because we're blocking
         // the next activity from showing up until we finish.
 
         // onPause will be followed by either onResume or onStop.
         super.onPause();
-
-        mMemoryWatcher.StopMemoryWatcher();
     }
 
     @Override
     public void onResume()
     {
         Log.i("GeckoApp", "resume");
         if (checkLaunchState(LaunchState.GeckoRunning))
             GeckoAppShell.onResume();
         // After an onPause, the activity is back in the foreground.
         // Undo whatever we did in onPause.
         super.onResume();
 
         // Just in case. Normally we start in onNewIntent
         if (checkLaunchState(LaunchState.PreLaunch) ||
             checkLaunchState(LaunchState.Launching))
             onNewIntent(getIntent());
-
-        mMemoryWatcher.StartMemoryWatcher();
     }
 
     @Override
     public void onStop()
     {
         Log.i("GeckoApp", "stop");
         // We're about to be stopped, potentially in preparation for
         // being destroyed.  We're killable after this point -- as I
@@ -348,18 +341,16 @@ abstract public class GeckoApp
         Log.i("GeckoApp", "configuration changed");
         // nothing, just ignore
         super.onConfigurationChanged(newConfig);
     }
 
     @Override
     public void onLowMemory()
     {
-        // if you change this handler, please take a look at
-        // MemoryWatcher too.
         Log.e("GeckoApp", "low memory");
         if (checkLaunchState(LaunchState.GeckoRunning))
             GeckoAppShell.onLowMemory();
         super.onLowMemory();
     }
 
     abstract public String getPackageName();
     abstract public String getContentProcessName();
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -92,17 +92,16 @@ class GeckoAppShell
     public static native void nativeInit();
     public static native void nativeRun(String args);
 
     // 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 onCriticalOOM();
     public static native void callObserver(String observerKey, String topic, String data);
     public static native void removeObserver(String observerKey);
     public static native void loadLibs(String apkName, boolean shouldExtract);
     public static native void onChangeNetworkLinkStatus(String status);
 
     public static File getCacheDir() {
         if (sCacheFile == null)
             sCacheFile = GeckoApp.mAppContext.getCacheDir();
@@ -132,17 +131,17 @@ class GeckoAppShell
         for (int c = 1; env != null; c++) {
             GeckoAppShell.putenv(env);
             env = i.getStringExtra("env" + c);
             Log.i("GeckoApp", "env"+ c +": "+ env);
         }
 
         // On some device, we do not want to ever over-allocate.
         if (android.os.Build.MODEL.equals("Nexus S") == true)
-            GeckoAppShell.putenv("MALLOC_OPTIONS=-o");
+            GeckoAppShell.putenv("MALLOC_OPTIONS=o");
 
         File f = new File("/data/data/" + 
                           GeckoApp.mAppContext.getPackageName() + "/tmp");
         if (!f.exists())
             f.mkdirs();
 
         GeckoAppShell.putenv("TMPDIR=" + f.getPath());
 
--- a/embedding/android/Makefile.in
+++ b/embedding/android/Makefile.in
@@ -48,17 +48,16 @@ DIRS = locales
 JAVAFILES = \
   GeckoApp.java \
   GeckoAppShell.java \
   GeckoConnectivityReceiver.java \
   GeckoEvent.java \
   GeckoSurfaceView.java \
   GeckoInputConnection.java \
   AlertNotification.java \
-  MemoryWatcher.java \
   $(NULL)
 
 PROCESSEDJAVAFILES = \
   App.java \
   Restarter.java \
   NotificationHandler.java \
   $(NULL)
 
--- a/other-licenses/android/APKOpen.cpp
+++ b/other-licenses/android/APKOpen.cpp
@@ -231,17 +231,16 @@ Java_org_mozilla_gecko_GeckoAppShell_ ##
 }
 
 SHELL_WRAPPER0(nativeInit)
 SHELL_WRAPPER1(nativeRun, jstring)
 SHELL_WRAPPER1(notifyGeckoOfEvent, jobject)
 SHELL_WRAPPER1(setSurfaceView, jobject)
 SHELL_WRAPPER0(onResume)
 SHELL_WRAPPER0(onLowMemory)
-SHELL_WRAPPER0(onCriticalOOM)
 SHELL_WRAPPER3(callObserver, jstring, jstring, jstring)
 SHELL_WRAPPER1(removeObserver, jstring)
 SHELL_WRAPPER1(onChangeNetworkLinkStatus, jstring)
 
 static void * xul_handle = NULL;
 static time_t apk_mtime = 0;
 #ifdef DEBUG
 extern "C" int extractLibs = 1;
@@ -662,17 +661,16 @@ loadLibs(const char *apkName)
 
 #define GETFUNC(name) f_ ## name = (name ## _t) __wrap_dlsym(xul_handle, "Java_org_mozilla_gecko_GeckoAppShell_" #name)
   GETFUNC(nativeInit);
   GETFUNC(nativeRun);
   GETFUNC(notifyGeckoOfEvent);
   GETFUNC(setSurfaceView);
   GETFUNC(onResume);
   GETFUNC(onLowMemory);
-  GETFUNC(onCriticalOOM);
   GETFUNC(callObserver);
   GETFUNC(removeObserver);
   GETFUNC(onChangeNetworkLinkStatus);
 #undef GETFUNC
   gettimeofday(&t1, 0);
   struct rusage usage2;
   getrusage(RUSAGE_SELF, &usage2);
   __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Loaded libs in %dms total, %d faults",
--- a/widget/src/android/AndroidJNI.cpp
+++ b/widget/src/android/AndroidJNI.cpp
@@ -61,17 +61,16 @@ using namespace mozilla;
 /* Forward declare all the JNI methods as extern "C" */
 
 extern "C" {
     NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_nativeInit(JNIEnv *, jclass);
     NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(JNIEnv *, jclass, jobject event);
     NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_setSurfaceView(JNIEnv *jenv, jclass, jobject sv);
     NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_onResume(JNIEnv *, jclass);
     NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_onLowMemory(JNIEnv *, jclass);
-    NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_onCriticalOOM(JNIEnv *, jclass);
     NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_callObserver(JNIEnv *, jclass, jstring observerKey, jstring topic, jstring data);
     NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_removeObserver(JNIEnv *jenv, jclass, jstring jObserverKey);
     NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_onChangeNetworkLinkStatus(JNIEnv *, jclass, jstring status);
 }
 
 
 /*
  * Incoming JNI methods
@@ -103,27 +102,16 @@ Java_org_mozilla_gecko_GeckoAppShell_onL
     if (nsAppShell::gAppShell) {
         nsAppShell::gAppShell->NotifyObservers(nsnull,
                                                "memory-pressure",
                                                NS_LITERAL_STRING("low-memory").get());
     }
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_onCriticalOOM(JNIEnv *jenv, jclass jc)
-{
-    __android_log_print(ANDROID_LOG_ERROR, "GeckoAppShell", "Critical OOM reached!");
-    if (nsAppShell::gAppShell) {
-        nsAppShell::gAppShell->NotifyObservers(nsnull,
-                                               "memory-pressure",
-                                               NS_LITERAL_STRING("oom-kill").get());
-    }
-}
-
-NS_EXPORT void JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_onResume(JNIEnv *jenv, jclass jc)
 {
     if (nsAppShell::gAppShell)
         nsAppShell::gAppShell->OnResume();
 }
 
 NS_EXPORT void JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_callObserver(JNIEnv *jenv, jclass, jstring jObserverKey, jstring jTopic, jstring jData)
--- a/xpcom/base/nsIMemory.idl
+++ b/xpcom/base/nsIMemory.idl
@@ -62,22 +62,16 @@
  * This will be passed as the extra data when the pressure 
  * observer is being asked to flush because of a heap minimize 
  * call.
  *
  * "alloc-failure"
  * This will be passed as the extra data when the pressure 
  * observer has been asked to flush because a malloc() or 
  * realloc() has failed.
- * 
- * "oom-kill"
- * This will be passed as the extra data when the pressure
- * observer notices that the application will crash or the
- * system will hang if immediate steps are not taken to
- * free as much as possible.
  */
 
 [scriptable, uuid(59e7e77a-38e4-11d4-8cf5-0060b0fc14a3)]
 interface nsIMemory : nsISupports
 {
     /**
      * Allocates a block of memory of a particular size. If the memory 
      * cannot be allocated (because of an out-of-memory condition), null