diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 4bdef33c527..ca196599f8f 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -173,8 +173,9 @@ public: uint32_t currentSize, bool shouldUseOldMaxSmartSize); -private: bool PermittedToSmartSize(nsIPrefBranch*, bool firstRun); + +private: bool mHaveProfile; bool mDiskCacheEnabled; @@ -1595,28 +1596,27 @@ public: if (!nsCacheService::gService || !nsCacheService::gService->mObserver) return NS_ERROR_NOT_AVAILABLE; - nsDisableOldMaxSmartSizePrefEvent::DisableOldMaxSmartSizePref(true); - return NS_OK; - } - - static void DisableOldMaxSmartSizePref(bool async) - { nsCOMPtr branch = do_GetService(NS_PREFSERVICE_CONTRACTID); if (!branch) { - return; + return NS_ERROR_NOT_AVAILABLE; } nsresult rv = branch->SetBoolPref(DISK_CACHE_USE_OLD_MAX_SMART_SIZE_PREF, false); if (NS_FAILED(rv)) { NS_WARNING("Failed to disable old max smart size"); - return; + return rv; } - if (async) { - nsCacheService::SetDiskSmartSize(); - } else { - nsCacheService::gService->SetDiskSmartSize_Locked(); + nsCacheService::SetDiskSmartSize(); + + if (nsCacheService::gService->mObserver->PermittedToSmartSize(branch, false)) { + rv = branch->SetIntPref(DISK_CACHE_CAPACITY_PREF, MAX_CACHE_SIZE); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to set cache capacity pref"); + } } + + return NS_OK; } }; @@ -1630,11 +1630,9 @@ nsCacheService::MarkStartingFresh() gService->mObserver->SetUseNewMaxSmartSize(true); - if (NS_IsMainThread()) { - nsDisableOldMaxSmartSizePrefEvent::DisableOldMaxSmartSizePref(false); - } else { - NS_DispatchToMainThread(new nsDisableOldMaxSmartSizePrefEvent()); - } + // We always dispatch an event here because we don't want to deal with lock + // reentrance issues. + NS_DispatchToMainThread(new nsDisableOldMaxSmartSizePrefEvent()); } nsresult