Bug 746548 - Fix NPE for cache service in pause/resume. r=mfinkle a=blocking-fennec
authorBrian Nicholson <bnicholson@mozilla.com>
Wed, 18 Apr 2012 13:08:36 -0700
changeset 95238 f6edc3d72a2275202c17dcff521bcd0bf6589fd2
parent 95237 a4d9b327cc69b18a4e2ccd8302148fd7164cb2ff
child 95239 31d07d8738379598f5c717655120e14cfcc4ccd2
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)
reviewersmfinkle, blocking-fennec
bugs746548
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 746548 - Fix NPE for cache service in pause/resume. r=mfinkle a=blocking-fennec
widget/android/nsAppShell.cpp
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -330,17 +330,18 @@ nsAppShell::ProcessNextNativeEvent(bool 
             // 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();
+            if (nsCacheService::GlobalInstance())
+                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
@@ -462,17 +463,18 @@ nsAppShell::ProcessNextNativeEvent(bool 
         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();
+            if (nsCacheService::GlobalInstance())
+                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;