Bug 630595. Backing out 37e4ab3abc44. r=blassey. a=blocking-fennec
authorDoug Turner <dougt@dougt.org>
Tue, 01 Feb 2011 22:34:12 -0800
changeset 61773 99af9d6485bb634aea32bfed429c064d8257d3c2
parent 61772 9dad67994e828eafb3813a4443d6dce3d0b57bec
child 61774 1bbbe11e29681528d1dedfd2b32dafc92f34bf1a
push id18482
push userdougt@mozilla.com
push dateWed, 02 Feb 2011 08:08:44 +0000
treeherdermozilla-central@1bbbe11e2968 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey, blocking-fennec
bugs630595
milestone2.0b11pre
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
Bug 630595. Backing out 37e4ab3abc44. r=blassey. a=blocking-fennec
embedding/android/GeckoApp.java
embedding/android/GeckoAppShell.java
embedding/android/GeckoEvent.java
embedding/android/Makefile.in
widget/src/android/AndroidJNI.cpp
widget/src/android/AndroidJavaWrappers.h
widget/src/android/Makefile.in
widget/src/android/nsAppShell.cpp
widget/src/android/nsAppShell.h
widget/src/android/nsMemoryWatcher.cpp
widget/src/android/nsMemoryWatcher.h
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -65,16 +65,17 @@ 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) {
@@ -208,16 +209,18 @@ 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);
@@ -267,33 +270,69 @@ 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.sendEventToGecko(new GeckoEvent(GeckoEvent.ACTIVITY_RESUMING));
-
+            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
+        // understand it, in extreme cases the process can be terminated
+        // without going through onDestroy.
+        //
+        // We might also get an onRestart after this; not sure what
+        // that would mean for Gecko if we were to kill it here.
+        // Instead, what we should do here is save prefs, session,
+        // etc., and generally mark the profile as 'clean', and then
+        // dirty it again if we get an onResume.
+
+        GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.ACTIVITY_STOPPING));
+        super.onStop();
+    }
+
+    @Override
+    public void onRestart()
+    {
+        Log.i("GeckoApp", "restart");
+        super.onRestart();
+    }
+
+    @Override
+    public void onStart()
+    {
+        Log.i("GeckoApp", "start");
+        super.onStart();
     }
 
     @Override
     public void onDestroy()
     {
         Log.i("GeckoApp", "destroy");
         // Tell Gecko to shutting down; we'll end up calling System.exit()
         // in onXreExit.
@@ -309,16 +348,18 @@ 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
@@ -90,16 +90,17 @@ class GeckoAppShell
 
     // Initialization methods
     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() {
--- a/embedding/android/GeckoEvent.java
+++ b/embedding/android/GeckoEvent.java
@@ -58,20 +58,21 @@ public class GeckoEvent {
     public static final int NATIVE_POKE = 0;
     public static final int KEY_EVENT = 1;
     public static final int MOTION_EVENT = 2;
     public static final int SENSOR_EVENT = 3;
     public static final int LOCATION_EVENT = 4;
     public static final int IME_EVENT = 5;
     public static final int DRAW = 6;
     public static final int SIZE_CHANGED = 7;
-    public static final int ACTIVITY_PAUSING = 8;
-    public static final int ACTIVITY_RESUMING = 9;
+    public static final int ACTIVITY_STOPPING = 8;
+    public static final int ACTIVITY_PAUSING = 9;
     public static final int ACTIVITY_SHUTDOWN = 10;
     public static final int LOAD_URI = 11;
+
     public static final int SURFACE_CREATED = 12;
     public static final int SURFACE_DESTROYED = 13;
 
     public static final int IME_COMPOSITION_END = 0;
     public static final int IME_COMPOSITION_BEGIN = 1;
     public static final int IME_SET_TEXT = 2;
     public static final int IME_GET_TEXT = 3;
     public static final int IME_DELETE_TEXT = 4;
--- a/embedding/android/Makefile.in
+++ b/embedding/android/Makefile.in
@@ -48,16 +48,17 @@ 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/widget/src/android/AndroidJNI.cpp
+++ b/widget/src/android/AndroidJNI.cpp
@@ -59,16 +59,17 @@
 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);
 }
 
 
@@ -113,16 +114,23 @@ Java_org_mozilla_gecko_GeckoAppShell_onC
     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)
 {
     if (!nsAppShell::gAppShell)
         return;
 
     nsJNIString sObserverKey(jObserverKey, jenv);
     nsJNIString sTopic(jTopic, jenv);
     nsJNIString sData(jData, jenv);
--- a/widget/src/android/AndroidJavaWrappers.h
+++ b/widget/src/android/AndroidJavaWrappers.h
@@ -440,18 +440,18 @@ public:
         NATIVE_POKE = 0,
         KEY_EVENT = 1,
         MOTION_EVENT = 2,
         SENSOR_EVENT = 3,
         LOCATION_EVENT = 4,
         IME_EVENT = 5,
         DRAW = 6,
         SIZE_CHANGED = 7,
-        ACTIVITY_PAUSING = 8,
-        ACTIVITY_RESUMING = 9,
+        ACTIVITY_STOPPING = 8,
+        ACTIVITY_PAUSING = 9,
         ACTIVITY_SHUTDOWN = 10,
         LOAD_URI = 11,
         SURFACE_CREATED = 12,
         SURFACE_DESTROYED = 13,
         dummy_java_enum_list_end
     };
 
     enum {
--- a/widget/src/android/Makefile.in
+++ b/widget/src/android/Makefile.in
@@ -63,17 +63,16 @@ CPPSRCS	= \
 	nsLookAndFeel.cpp \
 	nsScreenManagerAndroid.cpp \
 	nsIdleServiceAndroid.cpp \
 	nsClipboard.cpp \
 	nsFilePicker.cpp \
 	nsIMEPicker.cpp \
 	nsDeviceContextAndroid.cpp \
 	nsPrintOptionsAndroid.cpp \
-	nsMemoryWatcher.cpp \
 	$(NULL)
 
 NOT_THERE_YET_CPPSRCS = \
 	nsQtKeyUtils.cpp \
 	nsBidiKeyboard.cpp \
 	nsDragService.cpp \
 	nsNativeThemeQt.cpp \
 	mozqwidget.cpp \
--- a/widget/src/android/nsAppShell.cpp
+++ b/widget/src/android/nsAppShell.cpp
@@ -44,17 +44,16 @@
 #include "nsIAppStartup.h"
 #include "nsIGeolocationProvider.h"
 #include "nsIPrefService.h"
 
 #include "mozilla/Services.h"
 #include "prenv.h"
 
 #include "AndroidBridge.h"
-#include "nsMemoryWatcher.h"
 #include "nsAccelerometerSystem.h"
 #include <android/log.h>
 #include <pthread.h>
 
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG
 #include "prlog.h"
 #endif
@@ -118,20 +117,16 @@ nsAppShell::Init()
     if (AndroidBridge::Bridge())
         AndroidBridge::Bridge()->NotifyAppShellReady();
 
     nsCOMPtr<nsIObserverService> obsServ =
             mozilla::services::GetObserverService();
     if (obsServ) {
         obsServ->AddObserver(this, "xpcom-shutdown", PR_FALSE);
     }
-
-    mMemoryWatcher = new nsMemoryWatcher();
-    if (mMemoryWatcher)
-        mMemoryWatcher->StartWatching();
     return rv;
 }
 
 NS_IMETHODIMP
 nsAppShell::Observe(nsISupports* aSubject,
                     const char* aTopic,
                     const PRUnichar* aData)
 {
@@ -251,49 +246,48 @@ nsAppShell::ProcessNextNativeEvent(PRBoo
             break;
 
         if (curEvent->GeoPosition())
             gLocationCallback->Update(curEvent->GeoPosition());
         else
             NS_WARNING("Received location event without geoposition!");
         break;
 
+    case AndroidGeckoEvent::ACTIVITY_STOPPING: {
+        nsCOMPtr<nsIObserverService> obsServ =
+          mozilla::services::GetObserverService();
+        NS_NAMED_LITERAL_STRING(minimize, "heap-minimize");
+        obsServ->NotifyObservers(nsnull, "memory-pressure", minimize.get());
+
+        break;
+    }
+
     case AndroidGeckoEvent::ACTIVITY_SHUTDOWN: {
         nsCOMPtr<nsIObserverService> obsServ =
           mozilla::services::GetObserverService();
         NS_NAMED_LITERAL_STRING(context, "shutdown-persist");
         obsServ->NotifyObservers(nsnull, "quit-application-granted", nsnull);
         obsServ->NotifyObservers(nsnull, "quit-application-forced", nsnull);
         obsServ->NotifyObservers(nsnull, "profile-change-net-teardown", context.get());
         obsServ->NotifyObservers(nsnull, "profile-change-teardown", context.get());
         obsServ->NotifyObservers(nsnull, "profile-before-change", context.get());
         nsCOMPtr<nsIAppStartup> appSvc = do_GetService("@mozilla.org/toolkit/app-startup;1");
         if (appSvc)
             appSvc->Quit(nsIAppStartup::eForceQuit);
-
-        if (mMemoryWatcher)
-            mMemoryWatcher->StopWatching();
         break;
     }
 
-    case AndroidGeckoEvent::ACTIVITY_RESUMING: {
-        if (mMemoryWatcher)
-            mMemoryWatcher->StartWatching();
-        break;
-    }
     case AndroidGeckoEvent::ACTIVITY_PAUSING: {
         // We really want to send a notification like profile-before-change,
         // but profile-before-change ends up shutting some things down instead
         // of flushing data
         nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
         if (prefs)
             prefs->SavePrefFile(nsnull);
 
-        if (mMemoryWatcher)
-            mMemoryWatcher->StopWatching();
         break;
     }
 
     case AndroidGeckoEvent::LOAD_URI: {
         nsCOMPtr<nsICommandLineRunner> cmdline
             (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
         if (!cmdline)
             break;
@@ -375,16 +369,21 @@ nsAppShell::RemoveNextEvent()
         mEventQueue.RemoveElementAt(0);
         if (ae->Type() == AndroidGeckoEvent::DRAW) {
             mNumDraws--;
         }
     }
     PR_Unlock(mQueueLock);
 }
 
+void
+nsAppShell::OnResume()
+{
+}
+
 nsresult
 nsAppShell::AddObserver(const nsAString &aObserverKey, nsIObserver *aObserver)
 {
     NS_ASSERTION(aObserver != nsnull, "nsAppShell::AddObserver: aObserver is null!");
     return mObserversHash.Put(aObserverKey, aObserver) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 /**
--- a/widget/src/android/nsAppShell.h
+++ b/widget/src/android/nsAppShell.h
@@ -38,18 +38,16 @@
 
 #ifndef nsAppShell_h__
 #define nsAppShell_h__
 
 #include "nsBaseAppShell.h"
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 #include "nsInterfaceHashtable.h"
-#include "nsMemoryWatcher.h"
-#include "nsAutoPtr.h"
 
 #include "prcvar.h"
 
 namespace mozilla {
 class AndroidGeckoEvent;
 bool ProcessNextEvent();
 void NotifyEvent();
 }
@@ -69,16 +67,17 @@ public:
     nsresult Init();
 
     void NotifyNativeEvent();
 
     virtual PRBool ProcessNextNativeEvent(PRBool mayWait);
 
     void PostEvent(mozilla::AndroidGeckoEvent *event);
     void RemoveNextEvent();
+    void OnResume();
 
     nsresult AddObserver(const nsAString &aObserverKey, nsIObserver *aObserver);
     void CallObserver(const nsAString &aObserverKey, const nsAString &aTopic, const nsAString &aData);
     void RemoveObserver(const nsAString &aObserverKey);
     void NotifyObservers(nsISupports *aSupports, const char *aTopic, const PRUnichar *aData);
 
 protected:
     virtual void ScheduleNativeEventCallback();
@@ -88,14 +87,12 @@ protected:
     PRLock *mQueueLock;
     PRLock *mCondLock;
     PRCondVar *mQueueCond;
     nsTArray<mozilla::AndroidGeckoEvent *> mEventQueue;
     nsInterfaceHashtable<nsStringHashKey, nsIObserver> mObserversHash;
 
     mozilla::AndroidGeckoEvent *GetNextEvent();
     mozilla::AndroidGeckoEvent *PeekNextEvent();
-
-    nsRefPtr<nsMemoryWatcher> mMemoryWatcher;
 };
 
 #endif // nsAppShell_h__
 
deleted file mode 100644
--- a/widget/src/android/nsMemoryWatcher.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- *   Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsMemoryWatcher.h"
-#include "nsComponentManagerUtils.h"
-#include "android/log.h"
-#include "nsString.h"
-#include "nsAppShell.h"
-
-NS_IMPL_ISUPPORTS1(nsMemoryWatcher, nsITimerCallback)
-
-// These numbers were determined by inspecting the /proc/meminfo
-// MemFree values on the Nexus S before there was a system failure.
-// Seting these numbers lower we'd see no time to recover (by killing
-// the child process).  Setting these numbers hight resulted in not
-// being able to load pages on phones with lots of services/apps
-// running.
-#define DEFAULT_TIMER_INTERVAL 2000
-#define DEFAULT_LOW_MEMORY_MARK 5000
-#define DEFAULT_HIGH_MEMORY_MARK 10000
-
-nsMemoryWatcher::nsMemoryWatcher()
-  : mLowWaterMark(DEFAULT_LOW_MEMORY_MARK)
-  , mHighWaterMark(DEFAULT_HIGH_MEMORY_MARK)
-  , mLastLowNotification(0)
-  , mLastHighNotification(0)
-  , mMemInfoFile(nsnull)
-{
-}
-
-nsMemoryWatcher::~nsMemoryWatcher()
-{
-  if (mTimer)
-    StopWatching();
-}
-
-void
-nsMemoryWatcher::StartWatching()
-{
-  if (mTimer)
-    return;
-  
-  mMemInfoFile = fopen("/proc/meminfo", "r");
-  NS_ASSERTION(mMemInfoFile, "Could not open /proc/meminfo for reading.");
-
-  mTimer = do_CreateInstance("@mozilla.org/timer;1");
-  NS_ASSERTION(mTimer, "Creating of a timer failed.");
-
-  mTimer->InitWithCallback(this, DEFAULT_TIMER_INTERVAL, nsITimer::TYPE_REPEATING_SLACK);
-}
-
-void
-nsMemoryWatcher::StopWatching()
-{
-  if (!mTimer)
-    return;
-
-  mTimer->Cancel();
-  mTimer = nsnull;
-
-  fclose(mMemInfoFile);
-  mMemInfoFile = nsnull;
-}
-
-NS_IMETHODIMP
-nsMemoryWatcher::Notify(nsITimer *aTimer)
-{
-  NS_ASSERTION(mMemInfoFile, "File* to /proc/meminfo is null");
-
-  rewind(mMemInfoFile);
-
-  long memFree = -1;
-  char line[256];
-
-  while (fgets(line, 256, mMemInfoFile)) {
-      sscanf(line, "MemFree: %ld kB", &memFree);
-  }
-  NS_ASSERTION(memFree > 0, "Free memory should be greater than zero");
-
-  if (memFree < mLowWaterMark) {
-      __android_log_print(ANDROID_LOG_WARN, "Gecko",
-                          "!!!!!!!!! Reached criticial memory level. MemFree = %ld",
-                          memFree);
-
-      if (PR_IntervalToSeconds(PR_IntervalNow() - mLastLowNotification) > 5) {
-          nsAppShell::gAppShell->NotifyObservers(nsnull,
-                                                 "memory-pressure",
-                                                 NS_LITERAL_STRING("oom-kill").get());
-          mLastLowNotification = PR_IntervalNow();
-      }
-      return NS_OK;
-  }
-  
-  if (memFree < mHighWaterMark) {
-      __android_log_print(ANDROID_LOG_WARN, "Gecko",
-                          "!!!!!!!!! Reached low memory level. MemFree = %ld",
-                          memFree);
-      if (PR_IntervalToSeconds(PR_IntervalNow() - mLastHighNotification) > 5) {
-          nsAppShell::gAppShell->NotifyObservers(nsnull,
-                                                 "memory-pressure",
-                                                 NS_LITERAL_STRING("low-memory").get());
-          mLastHighNotification = PR_IntervalNow();
-      }
-      // we should speed up the timer at this point so that we can more
-      // closely watch memory usage
-      aTimer->SetDelay(DEFAULT_TIMER_INTERVAL / 10);
-      return NS_OK;
-  }
-  
-  // Make sure the delay is set properly.
-  aTimer->SetDelay(DEFAULT_TIMER_INTERVAL);
-  return NS_OK;
-}
deleted file mode 100644
--- a/widget/src/android/nsMemoryWatcher.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: c++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4; -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- *   Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2011
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsMemoryWatcher_h__
-#define nsMemoryWatcher_h__
-
-#include <stdio.h>
-#include <prtime.h>
-#include <prinrval.h>
-#include <nsCOMPtr.h>
-#include <nsITimer.h>
-
-class nsMemoryWatcher : public nsITimerCallback
-{
-public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSITIMERCALLBACK
-
-    nsMemoryWatcher();
-    virtual ~nsMemoryWatcher();
-
-    void StartWatching();
-    void StopWatching();
-
-private:
-    long mTimerInterval;
-    long mLowWaterMark;
-    long mHighWaterMark;
-    PRIntervalTime mLastLowNotification;
-    PRIntervalTime mLastHighNotification;
-    nsCOMPtr<nsITimer> mTimer;
-    FILE* mMemInfoFile;
-};
-
-#endif /* nsMemoryWatcher_h__ */