Bug 678792 - Remove --disable-necko-disk-cache. r=khuey,jduell
authorMatheus Kerschbaum <matjk7@gmail.com>
Thu, 18 Aug 2011 11:53:26 +0200
changeset 76523 5046e7177feb47152e8b6cb82358f3e05e73cc50
parent 76522 63b8853b1d67da1b8c7a05ce9bb986157d58bb81
child 76524 8fbc35ff4d7cb1fa6df2acf0e6090e3428044e33
push idunknown
push userunknown
push dateunknown
reviewerskhuey, jduell
bugs678792
milestone9.0a1
Bug 678792 - Remove --disable-necko-disk-cache. r=khuey,jduell
config/autoconf.mk.in
configure.in
netwerk/cache/Makefile.in
netwerk/cache/nsCacheService.cpp
netwerk/necko-config.h.in
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -218,17 +218,16 @@ MOZ_POST_DSO_LIB_COMMAND = @MOZ_POST_DSO
 MOZ_POST_PROGRAM_COMMAND = @MOZ_POST_PROGRAM_COMMAND@
 
 MOZ_BUILD_ROOT             = @MOZ_BUILD_ROOT@
 
 MOZ_XUL                    = @MOZ_XUL@
 MOZ_RDF                    = @MOZ_RDF@
 
 NECKO_PROTOCOLS = @NECKO_PROTOCOLS@
-NECKO_DISK_CACHE = @NECKO_DISK_CACHE@
 NECKO_COOKIES = @NECKO_COOKIES@
 NECKO_WIFI = @NECKO_WIFI@
 MOZ_AUTH_EXTENSION = @MOZ_AUTH_EXTENSION@
 
 MOZ_NATIVE_HUNSPELL = @SYSTEM_HUNSPELL@
 MOZ_HUNSPELL_LIBS = @MOZ_HUNSPELL_LIBS@
 MOZ_HUNSPELL_CFLAGS = @MOZ_HUNSPELL_CFLAGS@
 
--- a/configure.in
+++ b/configure.in
@@ -4773,17 +4773,16 @@ MOZ_XTF=1
 MOZ_XUL=1
 MOZ_ZIPWRITER=1
 NS_PRINTING=1
 MOZ_PDF_PRINTING=
 MOZ_DISABLE_DOMCRYPTO=
 NSS_DISABLE_DBM=
 NECKO_WIFI=1
 NECKO_COOKIES=1
-NECKO_DISK_CACHE=1
 NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg"
 USE_ARM_KUSER=
 BUILD_CTYPES=1
 MOZ_USE_NATIVE_POPUP_WINDOWS=
 
 
 case "${target}" in
 *android*|*darwin*)
@@ -8760,29 +8759,16 @@ done],
 dnl Remove dupes
 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
 AC_SUBST(NECKO_PROTOCOLS)
 for p in $NECKO_PROTOCOLS; do
     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
 done
 
 dnl
-dnl option to disable necko's disk cache
-dnl
-MOZ_ARG_DISABLE_BOOL(necko-disk-cache,
-[  --disable-necko-disk-cache
-                          Disable necko disk cache],
-    NECKO_DISK_CACHE=,
-    NECKO_DISK_CACHE=1)
-AC_SUBST(NECKO_DISK_CACHE)
-if test "$NECKO_DISK_CACHE"; then
-    AC_DEFINE(NECKO_DISK_CACHE)
-fi
-
-dnl
 dnl option to disable necko's wifi scanner
 dnl
 MOZ_ARG_DISABLE_BOOL(necko-wifi,
 [  --disable-necko-wifi    Disable necko wifi scanner],
     NECKO_WIFI=,
     NECKO_WIFI=1)
 
 if test "$OS_ARCH" = "OS2"; then
--- a/netwerk/cache/Makefile.in
+++ b/netwerk/cache/Makefile.in
@@ -67,30 +67,25 @@ EXPORTS = \
 CPPSRCS = \
   nsCache.cpp \
   nsCacheEntry.cpp \
   nsCacheEntryDescriptor.cpp \
   nsCacheMetaData.cpp \
   nsCacheService.cpp \
   nsCacheSession.cpp \
   nsMemoryCacheDevice.cpp \
-  nsDiskCacheDeviceSQL.cpp \
-  $(NULL)
-
-ifdef NECKO_DISK_CACHE
-CPPSRCS += \
   nsDiskCacheBinding.cpp \
   nsDiskCacheBlockFile.cpp \
   nsDiskCacheDevice.cpp \
+  nsDiskCacheDeviceSQL.cpp \
   nsDiskCacheEntry.cpp \
   nsDiskCacheMap.cpp \
   nsDiskCacheStreams.cpp \
   nsDeleteDir.cpp \
   $(NULL)
-endif
 
 DEFINES += -DNECKO_OFFLINE_CACHE
 
 LOCAL_INCLUDES = \
   -I$(srcdir)/../base/src \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -107,23 +107,21 @@ using namespace mozilla;
 
 static const char * observerList[] = { 
     "profile-before-change",
     "profile-do-change",
     NS_XPCOM_SHUTDOWN_OBSERVER_ID,
     NS_PRIVATE_BROWSING_SWITCH_TOPIC
 };
 static const char * prefList[] = { 
-#ifdef NECKO_DISK_CACHE
     DISK_CACHE_ENABLE_PREF,
     DISK_CACHE_SMART_SIZE_ENABLED_PREF,
     DISK_CACHE_CAPACITY_PREF,
     DISK_CACHE_DIR_PREF,
     DISK_CACHE_MAX_ENTRY_SIZE_PREF,
-#endif
 #ifdef NECKO_OFFLINE_CACHE
     OFFLINE_CACHE_ENABLE_PREF,
     OFFLINE_CACHE_CAPACITY_PREF,
     OFFLINE_CACHE_DIR_PREF,
 #endif
     MEMORY_CACHE_ENABLE_PREF,
     MEMORY_CACHE_CAPACITY_PREF,
     MEMORY_CACHE_MAX_ENTRY_SIZE_PREF
@@ -405,17 +403,16 @@ nsCacheProfilePrefObserver::Observe(nsIS
         // ignore pref changes until we're done switch profiles
         if (!mHaveProfile)  
             return NS_OK;
 
         nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(subject, &rv);
         if (NS_FAILED(rv))  
             return rv;
 
-#ifdef NECKO_DISK_CACHE
         // which preference changed?
         if (!strcmp(DISK_CACHE_ENABLE_PREF, data.get())) {
 
             if (!mInPrivateBrowsing) {
                 rv = branch->GetBoolPref(DISK_CACHE_ENABLE_PREF,
                                          &mDiskCacheEnabled);
                 if (NS_FAILED(rv))  
                     return rv;
@@ -473,18 +470,17 @@ nsCacheProfilePrefObserver::Observe(nsIS
           
 #if 0            
         } else if (!strcmp(DISK_CACHE_DIR_PREF, data.get())) {
             // XXX We probaby don't want to respond to this pref except after
             // XXX profile changes.  Ideally, there should be somekind of user
             // XXX notification that the pref change won't take effect until
             // XXX the next time the profile changes (browser launch)
 #endif            
-        } else 
-#endif // !NECKO_DISK_CACHE
+        } else
 
 #ifdef NECKO_OFFLINE_CACHE
         // which preference changed?
         if (!strcmp(OFFLINE_CACHE_ENABLE_PREF, data.get())) {
 
             if (!mInPrivateBrowsing) {
                 rv = branch->GetBoolPref(OFFLINE_CACHE_ENABLE_PREF,
                                          &mOfflineCacheEnabled);
@@ -534,42 +530,36 @@ nsCacheProfilePrefObserver::Observe(nsIS
             nsCacheService::SetMemoryCacheMaxEntrySize(mMemoryCacheMaxEntrySize);
         }
     } else if (!strcmp(NS_PRIVATE_BROWSING_SWITCH_TOPIC, topic)) {
         if (!strcmp(NS_PRIVATE_BROWSING_ENTER, data.get())) {
             mInPrivateBrowsing = PR_TRUE;
 
             nsCacheService::OnEnterExitPrivateBrowsing();
 
-#ifdef NECKO_DISK_CACHE
             mDiskCacheEnabled = PR_FALSE;
             nsCacheService::SetDiskCacheEnabled(DiskCacheEnabled());
-#endif // !NECKO_DISK_CACHE
 
 #ifdef NECKO_OFFLINE_CACHE
             mOfflineCacheEnabled = PR_FALSE;
             nsCacheService::SetOfflineCacheEnabled(OfflineCacheEnabled());
 #endif // !NECKO_OFFLINE_CACHE
         } else if (!strcmp(NS_PRIVATE_BROWSING_LEAVE, data.get())) {
             mInPrivateBrowsing = PR_FALSE;
 
             nsCacheService::OnEnterExitPrivateBrowsing();
 
-#if defined(NECKO_DISK_CACHE) || defined(NECKO_OFFLINE_CACHE)
             nsCOMPtr<nsIPrefBranch> branch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
             if (NS_FAILED(rv))  
                 return rv;
-#endif // !NECKO_DISK_CACHE && !NECKO_OFFLINE_CACHE
-
-#ifdef NECKO_DISK_CACHE
+
             mDiskCacheEnabled = PR_TRUE; // by default enabled
             (void) branch->GetBoolPref(DISK_CACHE_ENABLE_PREF,
                                        &mDiskCacheEnabled);
             nsCacheService::SetDiskCacheEnabled(DiskCacheEnabled());
-#endif // !NECKO_DISK_CACHE
 
 #ifdef NECKO_OFFLINE_CACHE
             mOfflineCacheEnabled = PR_TRUE; // by default enabled
             (void) branch->GetBoolPref(OFFLINE_CACHE_ENABLE_PREF,
                                        &mOfflineCacheEnabled);
             nsCacheService::SetOfflineCacheEnabled(OfflineCacheEnabled());
 #endif // !NECKO_OFFLINE_CACHE
         }
@@ -669,17 +659,16 @@ nsCacheProfilePrefObserver::PermittedToS
 }
 
 
 nsresult
 nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch)
 {
     nsresult rv = NS_OK;
 
-#ifdef NECKO_DISK_CACHE
     // read disk cache device prefs
     if (!mInPrivateBrowsing) {
         mDiskCacheEnabled = PR_TRUE;  // presume disk cache is enabled
         (void) branch->GetBoolPref(DISK_CACHE_ENABLE_PREF, &mDiskCacheEnabled);
     }
 
     mDiskCacheCapacity = DISK_CACHE_CAPACITY;
     (void)branch->GetIntPref(DISK_CACHE_CAPACITY_PREF, &mDiskCacheCapacity);
@@ -765,17 +754,16 @@ nsCacheProfilePrefObserver::ReadPrefs(ns
         if (firstSmartSizeRun) {
             // It is no longer our first run
             rv = branch->SetBoolPref(DISK_CACHE_SMART_SIZE_FIRST_RUN_PREF, 
                                      PR_FALSE);
             if (NS_FAILED(rv)) 
                 NS_WARNING("Failed setting first_run pref in ReadPrefs.");
         }
     }
-#endif // !NECKO_DISK_CACHE
 
 #ifdef NECKO_OFFLINE_CACHE
     // read offline cache device prefs
     if (!mInPrivateBrowsing) {
         mOfflineCacheEnabled = PR_TRUE;  // presume offline cache is enabled
         (void) branch->GetBoolPref(OFFLINE_CACHE_ENABLE_PREF,
                                    &mOfflineCacheEnabled);
     }
@@ -1116,26 +1104,24 @@ nsCacheService::Shutdown()
         // to be safe
         NS_UnregisterMemoryReporter(MemoryCacheReporter);
         MemoryCacheReporter = nsnull;
 
         // deallocate memory and disk caches
         delete mMemoryDevice;
         mMemoryDevice = nsnull;
 
-#ifdef NECKO_DISK_CACHE
         delete mDiskDevice;
         mDiskDevice = nsnull;
-#endif // !NECKO_DISK_CACHE
 
 #ifdef NECKO_OFFLINE_CACHE
         NS_IF_RELEASE(mOfflineDevice);
 #endif // !NECKO_OFFLINE_CACHE
 
-#if defined(NECKO_DISK_CACHE) && defined(PR_LOGGING)
+#ifdef PR_LOGGING
         LogCacheStatistics();
 #endif
 
         mCacheIOThread.swap(cacheIOThread);
     }
     } // lock
 
     if (cacheIOThread)
@@ -1216,30 +1202,28 @@ nsCacheService::EvictEntriesForClient(co
                                       NS_CACHESERVICE_EMPTYCACHE_TOPIC_ID,
                                       nsnull);
         }
     }
 
     nsCacheServiceAutoLock lock;
     nsresult res = NS_OK;
 
-#ifdef NECKO_DISK_CACHE
     if (storagePolicy == nsICache::STORE_ANYWHERE ||
         storagePolicy == nsICache::STORE_ON_DISK) {
 
         if (mEnableDiskDevice) {
             nsresult rv;
             if (!mDiskDevice)
                 rv = CreateDiskDevice();
             if (mDiskDevice)
                 rv = mDiskDevice->EvictEntries(clientID);
             if (NS_FAILED(rv)) res = rv;
         }
     }
-#endif // ! NECKO_DISK_CACHE
 
 #ifdef NECKO_OFFLINE_CACHE
     // Only clear the offline cache if it has been specifically asked for.
     if (storagePolicy == nsICache::STORE_OFFLINE) {
         if (mEnableOfflineDevice) {
             nsresult rv;
             if (!mOfflineDevice)
                 rv = CreateOfflineDevice();
@@ -1313,26 +1297,24 @@ NS_IMETHODIMP nsCacheService::VisitEntri
     
     nsresult rv = NS_OK;
     // If there is no memory device, there are then also no entries to visit...
     if (mMemoryDevice) {
         rv = mMemoryDevice->Visit(visitor);
         if (NS_FAILED(rv)) return rv;
     }
 
-#ifdef NECKO_DISK_CACHE
     if (mEnableDiskDevice) {
         if (!mDiskDevice) {
             rv = CreateDiskDevice();
             if (NS_FAILED(rv)) return rv;
         }
         rv = mDiskDevice->Visit(visitor);
         if (NS_FAILED(rv)) return rv;
     }
-#endif // !NECKO_DISK_CACHE
 
 #ifdef NECKO_OFFLINE_CACHE
     if (mEnableOfflineDevice) {
         if (!mOfflineDevice) {
             rv = CreateOfflineDevice();
             if (NS_FAILED(rv)) return rv;
         }
         rv = mOfflineDevice->Visit(visitor);
@@ -1364,17 +1346,16 @@ NS_IMETHODIMP nsCacheService::GetCacheIO
 }
 
 /**
  * Internal Methods
  */
 nsresult
 nsCacheService::CreateDiskDevice()
 {
-#ifdef NECKO_DISK_CACHE
     if (!mInitialized)      return NS_ERROR_NOT_AVAILABLE;
     if (!mEnableDiskDevice) return NS_ERROR_NOT_AVAILABLE;
     if (mDiskDevice)        return NS_OK;
 
     mDiskDevice = new nsDiskCacheDevice;
     if (!mDiskDevice)       return NS_ERROR_OUT_OF_MEMORY;
 
     // set the preferences
@@ -1390,20 +1371,16 @@ nsCacheService::CreateDiskDevice()
         printf("###    - disabling disk cache for this session.\n");
         printf("###\n");
 #endif        
         mEnableDiskDevice = PR_FALSE;
         delete mDiskDevice;
         mDiskDevice = nsnull;
     }
     return rv;
-#else // !NECKO_DISK_CACHE
-    NS_NOTREACHED("nsCacheService::CreateDiskDevice");
-    return NS_ERROR_NOT_IMPLEMENTED;
-#endif
 }
 
 nsresult
 nsCacheService::CreateOfflineDevice()
 {
 #ifdef NECKO_OFFLINE_CACHE
     CACHE_LOG_ALWAYS(("Creating offline device"));
 
@@ -1425,17 +1402,17 @@ nsCacheService::CreateOfflineDevice()
     if (NS_FAILED(rv)) {
         CACHE_LOG_DEBUG(("mOfflineDevice->Init() failed (0x%.8x)\n", rv));
         CACHE_LOG_DEBUG(("    - disabling offline cache for this session.\n"));
 
         mEnableOfflineDevice = PR_FALSE;
         NS_RELEASE(mOfflineDevice);
     }
     return rv;
-#else // !NECKO_DISK_CACHE
+#else // !NECKO_OFFLINE_CACHE
     NS_NOTREACHED("nsCacheService::CreateOfflineDevice");
     return NS_ERROR_NOT_IMPLEMENTED;
 #endif
 }
 
 nsresult
 nsCacheService::CreateMemoryDevice()
 {
@@ -1815,27 +1792,25 @@ nsCacheService::SearchCacheDevices(nsCSt
             CACHE_LOG_DEBUG(("Searching mMemoryDevice for key %s found: 0x%p, "
                              "collision: %d\n", key->get(), entry, collision));
         }
     }
 
     if (!entry && 
         ((policy == nsICache::STORE_ANYWHERE) || (policy == nsICache::STORE_ON_DISK))) {
 
-#ifdef NECKO_DISK_CACHE
         if (mEnableDiskDevice) {
             if (!mDiskDevice) {
                 nsresult rv = CreateDiskDevice();
                 if (NS_FAILED(rv))
                     return nsnull;
             }
             
             entry = mDiskDevice->FindEntry(key, collision);
         }
-#endif // !NECKO_DISK_CACHE
     }
 
     if (!entry && (policy == nsICache::STORE_OFFLINE ||
                    (policy == nsICache::STORE_ANYWHERE &&
                     gIOService->IsOffline()))) {
 
 #ifdef NECKO_OFFLINE_CACHE
         if (mEnableOfflineDevice) {
@@ -1858,17 +1833,16 @@ nsCacheDevice *
 nsCacheService::EnsureEntryHasDevice(nsCacheEntry * entry)
 {
     nsCacheDevice * device = entry->CacheDevice();
     // return device if found, possibly null if the entry is doomed i.e prevent
     // doomed entries to bind to a device (see e.g. bugs #548406 and #596443)
     if (device || entry->IsDoomed())  return device;
 
     PRInt64 predictedDataSize = entry->PredictedDataSize();
-#ifdef NECKO_DISK_CACHE
     if (entry->IsStreamData() && entry->IsAllowedOnDisk() && mEnableDiskDevice) {
         // this is the default
         if (!mDiskDevice) {
             (void)CreateDiskDevice();  // ignore the error (check for mDiskDevice instead)
         }
 
         if (mDiskDevice) {
             // Bypass the cache if Content-Length says the entry will be too big
@@ -1882,17 +1856,16 @@ nsCacheService::EnsureEntryHasDevice(nsC
 
             entry->MarkBinding();  // enter state of binding
             nsresult rv = mDiskDevice->BindEntry(entry);
             entry->ClearBinding(); // exit state of binding
             if (NS_SUCCEEDED(rv))
                 device = mDiskDevice;
         }
     }
-#endif // !NECKO_DISK_CACHE
 
     // if we can't use mDiskDevice, try mMemoryDevice
     if (!device && mEnableMemoryDevice && entry->IsAllowedInMemory()) {        
         if (!mMemoryDevice) {
             (void)CreateMemoryDevice();  // ignore the error (check for mMemoryDevice instead)
         }
         if (mMemoryDevice) {
             // Bypass the cache if Content-Length says entry will be too big
@@ -1999,25 +1972,23 @@ nsCacheService::OnProfileShutdown(PRBool
 
     gService->DoomActiveEntries();
     gService->ClearDoomList();
 
     // Make sure to wait for any pending cache-operations before
     // proceeding with destructive actions (bug #620660)
     (void) SyncWithCacheIOThread();
 
-#ifdef NECKO_DISK_CACHE
     if (gService->mDiskDevice && gService->mEnableDiskDevice) {
         if (cleanse)
             gService->mDiskDevice->EvictEntries(nsnull);
 
         gService->mDiskDevice->Shutdown();
     }
     gService->mEnableDiskDevice = PR_FALSE;
-#endif // !NECKO_DISK_CACHE
 
 #ifdef NECKO_OFFLINE_CACHE
     if (gService->mOfflineDevice && gService->mEnableOfflineDevice) {
         if (cleanse)
             gService->mOfflineDevice->EvictEntries(nsnull);
 
         gService->mOfflineDevice->Shutdown();
     }
@@ -2040,30 +2011,28 @@ nsCacheService::OnProfileChanged()
     CACHE_LOG_DEBUG(("nsCacheService::OnProfileChanged"));
  
     nsCacheServiceAutoLock lock;
     
     gService->mEnableDiskDevice    = gService->mObserver->DiskCacheEnabled();
     gService->mEnableOfflineDevice = gService->mObserver->OfflineCacheEnabled();
     gService->mEnableMemoryDevice  = gService->mObserver->MemoryCacheEnabled();
 
-#ifdef NECKO_DISK_CACHE
     if (gService->mDiskDevice) {
         gService->mDiskDevice->SetCacheParentDirectory(gService->mObserver->DiskCacheParentDirectory());
         gService->mDiskDevice->SetCapacity(gService->mObserver->DiskCacheCapacity());
 
         // XXX initialization of mDiskDevice could be made lazily, if mEnableDiskDevice is false
         nsresult rv = gService->mDiskDevice->Init();
         if (NS_FAILED(rv)) {
             NS_ERROR("nsCacheService::OnProfileChanged: Re-initializing disk device failed");
             gService->mEnableDiskDevice = PR_FALSE;
             // XXX delete mDiskDevice?
         }
     }
-#endif // !NECKO_DISK_CACHE
 
 #ifdef NECKO_OFFLINE_CACHE
     if (gService->mOfflineDevice) {
         gService->mOfflineDevice->SetCacheParentDirectory(gService->mObserver->OfflineCacheParentDirectory());
         gService->mOfflineDevice->SetCapacity(gService->mObserver->OfflineCacheCapacity());
 
         // XXX initialization of mOfflineDevice could be made lazily, if mEnableOfflineDevice is false
         nsresult rv = gService->mOfflineDevice->Init();
@@ -2103,37 +2072,33 @@ nsCacheService::SetDiskCacheEnabled(PRBo
 
 
 void
 nsCacheService::SetDiskCacheCapacity(PRInt32  capacity)
 {
     if (!gService)  return;
     nsCacheServiceAutoLock lock;
 
-#ifdef NECKO_DISK_CACHE
     if (gService->mDiskDevice) {
         gService->mDiskDevice->SetCapacity(capacity);
     }
-#endif // !NECKO_DISK_CACHE
-    
+
     if (gService->mObserver)
         gService->mEnableDiskDevice = gService->mObserver->DiskCacheEnabled();
 }
 
 void
 nsCacheService::SetDiskCacheMaxEntrySize(PRInt32  maxSize)
 {
     if (!gService)  return;
     nsCacheServiceAutoLock lock;
 
-#ifdef NECKO_DISK_CACHE
     if (gService->mDiskDevice) {
         gService->mDiskDevice->SetMaxEntrySize(maxSize);
     }
-#endif // !NECKO_DISK_CACHE
 }
 
 void
 nsCacheService::SetMemoryCacheMaxEntrySize(PRInt32  maxSize)
 {
     if (!gService)  return;
     nsCacheServiceAutoLock lock;
 
--- a/netwerk/necko-config.h.in
+++ b/netwerk/necko-config.h.in
@@ -32,18 +32,16 @@
  * 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 _NECKO_CONFIG_H_
 #define _NECKO_CONFIG_H_
 
-#undef NECKO_DISK_CACHE
-
 #undef NECKO_COOKIES
 
 #undef NECKO_WIFI
 
 #undef NECKO_PROTOCOL_about
 #undef NECKO_PROTOCOL_data
 #undef NECKO_PROTOCOL_device
 #undef NECKO_PROTOCOL_file