diff --git a/netwerk/cache2/CacheObserver.cpp b/netwerk/cache2/CacheObserver.cpp index c553e1fc6b1e..077ab5d0cfb8 100644 --- a/netwerk/cache2/CacheObserver.cpp +++ b/netwerk/cache2/CacheObserver.cpp @@ -208,11 +208,6 @@ CacheObserver::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } - if (!strcmp(aTopic, "browser-delayed-startup-finished")) { - CacheStorageService::CleaupCacheDirectories(); - return NS_OK; - } - if (!strcmp(aTopic, "profile-change-net-teardown") || !strcmp(aTopic, "profile-before-change") || !strcmp(aTopic, "xpcom-shutdown")) { diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index d48bb823548d..829f13463a58 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -553,72 +553,6 @@ void CacheStorageService::DropPrivateBrowsingEntries() { } } -namespace { - -class CleaupCacheDirectoriesRunnable : public Runnable { - public: - NS_DECL_NSIRUNNABLE - static bool Post(); - - private: - CleaupCacheDirectoriesRunnable() - : Runnable("net::CleaupCacheDirectoriesRunnable") { - CacheFileIOManager::GetCacheDirectory(getter_AddRefs(mCache2Dir)); -#if defined(MOZ_WIDGET_ANDROID) - CacheFileIOManager::GetProfilelessCacheDirectory( - getter_AddRefs(mCache2Profileless)); -#endif - } - - virtual ~CleaupCacheDirectoriesRunnable() = default; - nsCOMPtr mCache1Dir, mCache2Dir; -#if defined(MOZ_WIDGET_ANDROID) - nsCOMPtr mCache2Profileless; -#endif -}; - -// static -bool CleaupCacheDirectoriesRunnable::Post() { - // TODO: initialize nsDeleteDir - return true; -} - -NS_IMETHODIMP CleaupCacheDirectoriesRunnable::Run() { - MOZ_ASSERT(!NS_IsMainThread()); - - if (mCache1Dir) { - nsDeleteDir::RemoveOldTrashes(mCache1Dir); - } - if (mCache2Dir) { - nsDeleteDir::RemoveOldTrashes(mCache2Dir); - } -#if defined(MOZ_WIDGET_ANDROID) - if (mCache2Profileless) { - nsDeleteDir::RemoveOldTrashes(mCache2Profileless); - // Always delete the profileless cache on Android - nsDeleteDir::DeleteDir(mCache2Profileless, true, 30000); - } -#endif - - if (mCache1Dir) { - nsDeleteDir::DeleteDir(mCache1Dir, true, 30000); - } - - return NS_OK; -} - -} // namespace - -// static -void CacheStorageService::CleaupCacheDirectories() { - // Make sure we schedule just once in case CleaupCacheDirectories gets called - // multiple times from some reason. - static bool runOnce = CleaupCacheDirectoriesRunnable::Post(); - if (!runOnce) { - NS_WARNING("Could not start cache trashes cleanup"); - } -} - // Helper methods // static diff --git a/netwerk/cache2/CacheStorageService.h b/netwerk/cache2/CacheStorageService.h index efe07e88b042..c3ef1f2c990f 100644 --- a/netwerk/cache2/CacheStorageService.h +++ b/netwerk/cache2/CacheStorageService.h @@ -90,10 +90,6 @@ class CacheStorageService final : public nsICacheStorageService, void Shutdown(); void DropPrivateBrowsingEntries(); - // Takes care of deleting any pending trashes for both cache1 and cache2 - // as well as old cache directory. - static void CleaupCacheDirectories(); - static CacheStorageService* Self() { return sSelf; } static nsISupports* SelfISupports() { return static_cast(Self());