Bug 596808 - nsDiskCacheDevice::Init() called twice resulting in no disk cache available r=jduell, a=betaN
authorBjarne Herland <bjarne@runitsoft.com>
Thu, 16 Sep 2010 20:21:16 -0700
changeset 54219 b47978b94fc9b8fef14d47261eb6c168c528c3c3
parent 54218 191d6bb957b0e9fdf7dd2d7d49c6fff9f240132a
child 54220 a3607267900e3326e240f1dca93e37b2fc8bd14a
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell, betaN
bugs596808
milestone2.0b7pre
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 596808 - nsDiskCacheDevice::Init() called twice resulting in no disk cache available r=jduell, a=betaN
netwerk/cache/nsCacheService.cpp
netwerk/cache/nsDiskCache.h
netwerk/cache/nsDiskCacheDevice.cpp
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -104,17 +104,17 @@
 #define OFFLINE_CACHE_CAPACITY      512000
 
 #define MEMORY_CACHE_ENABLE_PREF    "browser.cache.memory.enable"
 #define MEMORY_CACHE_CAPACITY_PREF  "browser.cache.memory.capacity"
 #define MEMORY_CACHE_MAX_ENTRY_SIZE_PREF "browser.cache.memory.max_entry_size"
 
 static const char * observerList[] = { 
     "profile-before-change",
-    "profile-after-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,
@@ -359,17 +359,17 @@ nsCacheProfilePrefObserver::Observe(nsIS
     } else if (!strcmp("profile-before-change", topic)) {
         // profile before change
         mHaveProfile = PR_FALSE;
 
         // XXX shutdown devices
         nsCacheService::OnProfileShutdown(!strcmp("shutdown-cleanse",
                                                   data.get()));
         
-    } else if (!strcmp("profile-after-change", topic)) {
+    } else if (!strcmp("profile-do-change", topic)) {
         // profile after change
         mHaveProfile = PR_TRUE;
         nsCOMPtr<nsIPrefBranch> branch = do_GetService(NS_PREFSERVICE_CONTRACTID);
         ReadPrefs(branch);
         nsCacheService::OnProfileChanged();
     
     } else if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, topic)) {
 
--- a/netwerk/cache/nsDiskCache.h
+++ b/netwerk/cache/nsDiskCache.h
@@ -48,17 +48,17 @@
 #ifdef XP_WIN
 #include <winsock.h>  // for htonl/ntohl
 #endif
 
 
 class nsDiskCache {
 public:
     enum {
-            kCurrentVersion = 0x0001000D      // format = 16 bits major version/16 bits minor version
+            kCurrentVersion = 0x0001000E      // format = 16 bits major version/16 bits minor version
     };
 
     enum { kData, kMetaData };
 
     // Parameter initval initializes internal state of hash function. Hash values are different
     // for the same text when different initval is used. It can be any random number.
     // 
     // It can be used for generating 64-bit hash value:
--- a/netwerk/cache/nsDiskCacheDevice.cpp
+++ b/netwerk/cache/nsDiskCacheDevice.cpp
@@ -363,17 +363,20 @@ nsDiskCacheDevice::~nsDiskCacheDevice()
  */
 nsresult
 nsDiskCacheDevice::Init()
 {
     NS_TIME_FUNCTION;
 
     nsresult rv;
 
-    NS_ENSURE_TRUE(!Initialized(), NS_ERROR_FAILURE);
+    if (Initialized()) {
+        NS_ERROR("Disk cache already initialized!");
+        return NS_ERROR_UNEXPECTED;
+    }
        
     if (!mCacheDirectory)
         return NS_ERROR_FAILURE;
 
     rv = mBindery.Init();
     if (NS_FAILED(rv))
         return rv;