Bug 745075 - Close disk cache when pausing. r=gbrown f=mfinkle,michal
authorBrian Nicholson <bnicholson@mozilla.com>
Tue, 17 Apr 2012 10:29:52 -0700
changeset 95195 ac561faaee40bd1c65e4b0dedd7522c2b10893a0
parent 95194 a0ecc336b66d10d65c6648cb43a823dafb9df1cf
child 95196 6b917c007510a7c4f7c75d542a9419bbf396c80a
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs745075
milestone14.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
Bug 745075 - Close disk cache when pausing. r=gbrown f=mfinkle,michal
widget/android/Makefile.in
widget/android/nsAppShell.cpp
--- a/widget/android/Makefile.in
+++ b/widget/android/Makefile.in
@@ -101,12 +101,13 @@ DEFINES += -D_IMPL_NS_WIDGET
 
 LOCAL_INCLUDES += \
 	-I$(topsrcdir)/widget/xpwidgets \
 	-I$(topsrcdir)/widget/shared \
 	-I$(topsrcdir)/dom/system/android \
 	-I$(topsrcdir)/toolkit/components/places \
 	-I$(topsrcdir)/docshell/base \
 	-I$(topsrcdir)/content/events/src \
+	-I$(topsrcdir)/netwerk/cache \
 	-I$(srcdir) \
 	$(NULL)
 
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -43,16 +43,17 @@
 #include "mozilla/Hal.h"
 #include "nsAppShell.h"
 #include "nsWindow.h"
 #include "nsThreadUtils.h"
 #include "nsICommandLineRunner.h"
 #include "nsIObserverService.h"
 #include "nsIAppStartup.h"
 #include "nsIGeolocationProvider.h"
+#include "nsCacheService.h"
 
 #include "mozilla/Services.h"
 #include "mozilla/unused.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Hal.h"
 #include "prenv.h"
 
 #include "AndroidBridge.h"
@@ -325,16 +326,21 @@ nsAppShell::ProcessNextNativeEvent(bool 
 
     case AndroidGeckoEvent::ACTIVITY_PAUSING: {
         if (curEvent->Flags() == 0) {
             // We aren't transferring to one of our own activities, so set
             // background status
             nsCOMPtr<nsIObserverService> obsServ =
                 mozilla::services::GetObserverService();
             obsServ->NotifyObservers(nsnull, "application-background", nsnull);
+
+            // If we are OOM killed with the disk cache enabled, the entire
+            // cache will be cleared (bug 105843), so shut down the cache here
+            // and re-init on resume
+            nsCacheService::GlobalInstance()->Shutdown();
         }
 
         // 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
         nsIPrefService* prefs = Preferences::GetService();
         if (prefs) {
             // reset the crash loop state
@@ -453,16 +459,21 @@ nsAppShell::ProcessNextNativeEvent(bool 
     case AndroidGeckoEvent::NETWORK_CHANGED: {
         hal::NotifyNetworkChange(hal::NetworkInformation(curEvent->Bandwidth(),
                                                          curEvent->CanBeMetered()));
         break;
     }
 
     case AndroidGeckoEvent::ACTIVITY_RESUMING: {
         if (curEvent->Flags() == 0) {
+            // If we are OOM killed with the disk cache enabled, the entire
+            // cache will be cleared (bug 105843), so shut down cache on pause
+            // and re-init here
+            nsCacheService::GlobalInstance()->Init();
+
             // We didn't return from one of our own activities, so restore
             // to foreground status
             nsCOMPtr<nsIObserverService> obsServ =
                 mozilla::services::GetObserverService();
             obsServ->NotifyObservers(nsnull, "application-foreground", nsnull);
         }
         break;
     }