Bug 485230. Add way to disable caching during development. r+sr=cbiesinger
authorJason Duell <jduell.mcbugs@gmail.com>
Wed, 05 Aug 2009 14:39:06 +1200
changeset 31140 73e08f744e9aa66bd5f942f60aac19dd2e13ab7e
parent 31139 945f97d56524f9a3993beb6875e110dca127ac6d
child 31142 1f823d3b7fbfab20641edaecfa9cd83fd12ba785
push id8388
push userrocallahan@mozilla.com
push dateWed, 05 Aug 2009 02:43:46 +0000
treeherdermozilla-central@73e08f744e9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs485230
milestone1.9.2a1pre
Bug 485230. Add way to disable caching during development. r+sr=cbiesinger
netwerk/cache/src/nsCacheService.cpp
--- a/netwerk/cache/src/nsCacheService.cpp
+++ b/netwerk/cache/src/nsCacheService.cpp
@@ -176,27 +176,27 @@ nsCacheProfilePrefObserver::Install()
 {
     nsresult rv, rv2 = NS_OK;
     
     // install profile-change observer
     nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1", &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_ARG(observerService);
     
-    for (int i=0; i<NS_ARRAY_LENGTH(observerList); i++) {
+    for (unsigned int i=0; i<NS_ARRAY_LENGTH(observerList); i++) {
         rv = observerService->AddObserver(this, observerList[i], PR_FALSE);
         if (NS_FAILED(rv)) 
             rv2 = rv;
     }
     
     // install preferences observer
     nsCOMPtr<nsIPrefBranch2> branch = do_GetService(NS_PREFSERVICE_CONTRACTID);
     if (!branch) return NS_ERROR_FAILURE;
 
-    for (int i=0; i<NS_ARRAY_LENGTH(prefList); i++) {
+    for (unsigned int i=0; i<NS_ARRAY_LENGTH(prefList); i++) {
         rv = branch->AddObserver(prefList[i], this, PR_FALSE);
         if (NS_FAILED(rv))
             rv2 = rv;
     }
 
     // determine the initial status of the private browsing mode
     nsCOMPtr<nsIPrivateBrowsingService> pbs =
       do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
@@ -226,26 +226,26 @@ nsCacheProfilePrefObserver::Install()
 
 void
 nsCacheProfilePrefObserver::Remove()
 {
     // remove Observer Service observers
     nsCOMPtr<nsIObserverService> obs =
             do_GetService("@mozilla.org/observer-service;1");
     if (obs) {
-        for (int i=0; i<NS_ARRAY_LENGTH(observerList); i++) {
+        for (unsigned int i=0; i<NS_ARRAY_LENGTH(observerList); i++) {
             obs->RemoveObserver(this, observerList[i]);
         }
     }
 
     // remove Pref Service observers
     nsCOMPtr<nsIPrefBranch2> prefs =
            do_GetService(NS_PREFSERVICE_CONTRACTID);
     if (prefs) {
-        for (int i=0; i<NS_ARRAY_LENGTH(prefList); i++) {
+        for (unsigned int i=0; i<NS_ARRAY_LENGTH(prefList); i++) {
             // remove cache pref observers
             prefs->RemoveObserver(prefList[i], this);
         }
     }
 }
 
 
 NS_IMETHODIMP
@@ -444,23 +444,21 @@ nsCacheProfilePrefObserver::ReadPrefs(ns
                     if (NS_SUCCEEDED(rv)) {
                         PRBool exists;
                         if (NS_SUCCEEDED(profDir->Exists(&exists)) && exists)
                             DeleteDir(profDir, PR_FALSE, PR_FALSE);
                     }
                 }
             }
         }
-#if DEBUG
-        if (!directory) {
-            // use current process directory during development
+        // use file cache in build tree only if asked, to avoid cache dir litter
+        if (!directory && PR_GetEnv("NECKO_DEV_ENABLE_DISK_CACHE")) {
             rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
                                         getter_AddRefs(directory));
         }
-#endif
         if (directory)
             mDiskCacheParentDirectory = do_QueryInterface(directory, &rv);
     }
 #endif // !NECKO_DISK_CACHE
 
 #ifdef NECKO_OFFLINE_CACHE
     // read offline cache device prefs
     if (!mInPrivateBrowsing) {