From 8030ac3f2d810c8985091fcd31360a67600c0f06 Mon Sep 17 00:00:00 2001 From: Michal Novotny Date: Thu, 24 Aug 2017 10:25:38 +0200 Subject: [PATCH] Bug 1382688 - Do not allow to enable old disk cache backend, r=honzab --- modules/libpref/init/all.js | 8 - netwerk/base/nsLoadGroup.cpp | 66 ++----- netwerk/cache/nsCacheService.cpp | 43 +---- netwerk/cache2/CacheFileIOManager.cpp | 4 - netwerk/cache2/CacheObserver.cpp | 38 +--- netwerk/cache2/CacheObserver.h | 2 - netwerk/cache2/CacheStorageService.cpp | 166 +++++------------- netwerk/cache2/CacheStorageService.h | 4 +- netwerk/protocol/about/nsAboutCache.cpp | 18 +- netwerk/protocol/about/nsAboutCacheEntry.cpp | 22 --- netwerk/protocol/http/nsHttpChannel.cpp | 39 +--- netwerk/test/unit/head_cache.js | 2 +- netwerk/test/unit/head_cache2.js | 35 ++-- netwerk/test/unit/test_bug482934.js | 5 - .../test/unit/test_cache-control_request.js | 5 - .../test_cache2-01e-basic-bypass-if-busy.js | 5 - .../test_cache2-01f-basic-openTruncate.js | 5 - netwerk/test/unit/test_cache2-05-visit.js | 6 +- .../test/unit/test_cache2-07-visit-memory.js | 5 - .../test/unit/test_cache2-07a-open-memory.js | 5 - .../test_cache2-10b-evict-direct-immediate.js | 5 - .../test/unit/test_cache2-11-evict-memory.js | 6 +- .../test/unit/test_cache2-12-evict-disk.js | 7 +- ...t_cache2-14b-concurent-readers-complete.js | 6 +- .../unit/test_cache2-16-conditional-200.js | 5 - netwerk/test/unit/test_cache2-18-not-valid.js | 5 - netwerk/test/unit/test_cache2-19-range-206.js | 5 - netwerk/test/unit/test_cache2-20-range-200.js | 5 - .../test/unit/test_cache2-21-anon-storage.js | 5 - .../test/unit/test_cache2-22-anon-visit.js | 25 +-- .../unit/test_cache2-23-read-over-chunk.js | 5 - netwerk/test/unit/test_cache2-24-exists.js | 5 - .../unit/test_cache2-25-chunk-memory-limit.js | 5 - .../test_cache2-26-no-outputstream-open.js | 5 - .../unit/test_cache2-27-force-valid-for.js | 5 - ...-29d-concurrent_read_half-corrupted-206.js | 5 - ...e-concurrent_read_half-non-206-response.js | 5 - .../unit/test_cache2-30a-entry-pinning.js | 4 - .../test_cache2-30b-pinning-storage-clear.js | 5 +- .../test_cache2-30c-pinning-deferred-doom.js | 4 - .../test_cache2-30d-pinning-WasEvicted-API.js | 5 +- netwerk/test/unit/test_cache2-31-visit-all.js | 4 - netwerk/test/unit/test_cache_jar.js | 5 +- toolkit/components/telemetry/Histograms.json | 87 --------- .../telemetry/histogram-whitelists.json | 22 --- 45 files changed, 112 insertions(+), 616 deletions(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 113d11e0239c..ffc6ee5ac9b5 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -36,14 +36,6 @@ pref("general.warnOnAboutConfig", true); // maximum number of dated backups to keep at any time pref("browser.bookmarks.max_backups", 5); -// Delete HTTP cache v1 data -pref("browser.cache.auto_delete_cache_version", 0); -// Preference for switching the cache backend, can be changed freely at runtime -// 0 - use the old (Darin's) cache -// 1 - use the new cache back-end (cache v2) -pref("browser.cache.use_new_backend", 0); -pref("browser.cache.use_new_backend_temp", true); - pref("browser.cache.disk.enable", true); // Is this the first-time smartsizing has been introduced? pref("browser.cache.disk.smart_size.first_run", true); diff --git a/netwerk/base/nsLoadGroup.cpp b/netwerk/base/nsLoadGroup.cpp index 849c5426b4f0..e65592ec1109 100644 --- a/netwerk/base/nsLoadGroup.cpp +++ b/netwerk/base/nsLoadGroup.cpp @@ -963,25 +963,13 @@ nsLoadGroup::TelemetryReportChannel(nsITimedChannel *aTimedChannel, } \ \ if (!cacheReadStart.IsNull() && !cacheReadEnd.IsNull()) { \ - if (!CacheObserver::UseNewCache()) { \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_OPEN_TO_FIRST_FROM_CACHE, \ - asyncOpen, cacheReadStart); \ - } else { \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_OPEN_TO_FIRST_FROM_CACHE_V2, \ - asyncOpen, cacheReadStart); \ - } \ + Telemetry::AccumulateTimeDelta( \ + Telemetry::HTTP_##prefix##_OPEN_TO_FIRST_FROM_CACHE_V2, \ + asyncOpen, cacheReadStart); \ \ - if (!CacheObserver::UseNewCache()) { \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_CACHE_READ_TIME, \ - cacheReadStart, cacheReadEnd); \ - } else { \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_CACHE_READ_TIME_V2, \ - cacheReadStart, cacheReadEnd); \ - } \ + Telemetry::AccumulateTimeDelta( \ + Telemetry::HTTP_##prefix##_CACHE_READ_TIME_V2, \ + cacheReadStart, cacheReadEnd); \ \ if (!requestStart.IsNull() && !responseEnd.IsNull()) { \ Telemetry::AccumulateTimeDelta( \ @@ -991,38 +979,20 @@ nsLoadGroup::TelemetryReportChannel(nsITimedChannel *aTimedChannel, } \ \ if (!cacheReadEnd.IsNull()) { \ - if (!CacheObserver::UseNewCache()) { \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_COMPLETE_LOAD, \ - asyncOpen, cacheReadEnd); \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_COMPLETE_LOAD_CACHED, \ - asyncOpen, cacheReadEnd); \ - } else { \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_COMPLETE_LOAD_V2, \ - asyncOpen, cacheReadEnd); \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_COMPLETE_LOAD_CACHED_V2, \ - asyncOpen, cacheReadEnd); \ - } \ + Telemetry::AccumulateTimeDelta( \ + Telemetry::HTTP_##prefix##_COMPLETE_LOAD_V2, \ + asyncOpen, cacheReadEnd); \ + Telemetry::AccumulateTimeDelta( \ + Telemetry::HTTP_##prefix##_COMPLETE_LOAD_CACHED_V2, \ + asyncOpen, cacheReadEnd); \ } \ else if (!responseEnd.IsNull()) { \ - if (!CacheObserver::UseNewCache()) { \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_COMPLETE_LOAD, \ - asyncOpen, responseEnd); \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_COMPLETE_LOAD_NET, \ - asyncOpen, responseEnd); \ - } else { \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_COMPLETE_LOAD_V2, \ - asyncOpen, responseEnd); \ - Telemetry::AccumulateTimeDelta( \ - Telemetry::HTTP_##prefix##_COMPLETE_LOAD_NET_V2, \ - asyncOpen, responseEnd); \ - } \ + Telemetry::AccumulateTimeDelta( \ + Telemetry::HTTP_##prefix##_COMPLETE_LOAD_V2, \ + asyncOpen, responseEnd); \ + Telemetry::AccumulateTimeDelta( \ + Telemetry::HTTP_##prefix##_COMPLETE_LOAD_NET_V2, \ + asyncOpen, responseEnd); \ } if (aDefaultRequest) { diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 249a11e1f9ef..9db94fe78350 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -1314,10 +1314,7 @@ nsCacheService::CreateSession(const char * clientID, { *result = nullptr; - if (net::CacheObserver::UseNewCache()) - return NS_ERROR_NOT_IMPLEMENTED; - - return CreateSessionInternal(clientID, storagePolicy, streamBased, result); + return NS_ERROR_NOT_IMPLEMENTED; } nsresult @@ -1475,10 +1472,7 @@ nsCacheService::IsStorageEnabledForPolicy_Locked(nsCacheStoragePolicy storagePo NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor) { - if (net::CacheObserver::UseNewCache()) - return NS_ERROR_NOT_IMPLEMENTED; - - return VisitEntriesInternal(visitor); + return NS_ERROR_NOT_IMPLEMENTED; } nsresult nsCacheService::VisitEntriesInternal(nsICacheVisitor *visitor) @@ -1537,10 +1531,7 @@ void nsCacheService::FireClearNetworkCacheStoredAnywhereNotification() NS_IMETHODIMP nsCacheService::EvictEntries(nsCacheStoragePolicy storagePolicy) { - if (net::CacheObserver::UseNewCache()) - return NS_ERROR_NOT_IMPLEMENTED; - - return EvictEntriesInternal(storagePolicy); + return NS_ERROR_NOT_IMPLEMENTED; } nsresult nsCacheService::EvictEntriesInternal(nsCacheStoragePolicy storagePolicy) @@ -3108,33 +3099,7 @@ nsCacheService::SetDiskSmartSize() nsresult nsCacheService::SetDiskSmartSize_Locked() { - nsresult rv; - - if (mozilla::net::CacheObserver::UseNewCache()) { - return NS_ERROR_NOT_AVAILABLE; - } - - if (!mObserver->DiskCacheParentDirectory()) - return NS_ERROR_NOT_AVAILABLE; - - if (!mDiskDevice) - return NS_ERROR_NOT_AVAILABLE; - - if (!mObserver->SmartSizeEnabled()) - return NS_ERROR_NOT_AVAILABLE; - - nsAutoString cachePath; - rv = mObserver->DiskCacheParentDirectory()->GetPath(cachePath); - if (NS_SUCCEEDED(rv)) { - nsCOMPtr event = - new nsGetSmartSizeEvent(cachePath, mDiskDevice->getCacheSize(), - mObserver->ShouldUseOldMaxSmartSize()); - DispatchToCacheIOThread(event); - } else { - return NS_ERROR_FAILURE; - } - - return NS_OK; + return NS_ERROR_NOT_AVAILABLE; } void diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index 8daf44317737..ea3498d9971f 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -4265,10 +4265,6 @@ CacheFileIOManager::UpdateSmartCacheSize(int64_t aFreeSpace) nsresult rv; - if (!CacheObserver::UseNewCache()) { - return NS_ERROR_NOT_AVAILABLE; - } - if (!CacheObserver::SmartCacheSizeEnabled()) { return NS_ERROR_NOT_AVAILABLE; } diff --git a/netwerk/cache2/CacheObserver.cpp b/netwerk/cache2/CacheObserver.cpp index 37c834a1e75d..5af85590bea4 100644 --- a/netwerk/cache2/CacheObserver.cpp +++ b/netwerk/cache2/CacheObserver.cpp @@ -23,14 +23,6 @@ namespace net { CacheObserver* CacheObserver::sSelf = nullptr; -static uint32_t const kDefaultUseNewCache = 1; // Use the new cache by default -uint32_t CacheObserver::sUseNewCache = kDefaultUseNewCache; - -static bool sUseNewCacheTemp = false; // Temp trigger to not lose early adopters - -static int32_t const kAutoDeleteCacheVersion = -1; // Auto-delete off by default -static int32_t sAutoDeleteCacheVersion = kAutoDeleteCacheVersion; - static int32_t const kDefaultHalfLifeExperiment = -1; // Disabled int32_t CacheObserver::sHalfLifeExperiment = kDefaultHalfLifeExperiment; @@ -150,14 +142,6 @@ CacheObserver::Shutdown() void CacheObserver::AttachToPreferences() { - sAutoDeleteCacheVersion = mozilla::Preferences::GetInt( - "browser.cache.auto_delete_cache_version", kAutoDeleteCacheVersion); - - mozilla::Preferences::AddUintVarCache( - &sUseNewCache, "browser.cache.use_new_backend", kDefaultUseNewCache); - mozilla::Preferences::AddBoolVarCache( - &sUseNewCacheTemp, "browser.cache.use_new_backend_temp", false); - mozilla::Preferences::AddBoolVarCache( &sUseDiskCache, "browser.cache.disk.enable", kDefaultUseDiskCache); mozilla::Preferences::AddBoolVarCache( @@ -292,25 +276,6 @@ uint32_t CacheObserver::MemoryCacheCapacity() return sAutoMemoryCacheCapacity = capacity; } -// static -bool CacheObserver::UseNewCache() -{ - uint32_t useNewCache = sUseNewCache; - - if (sUseNewCacheTemp) - useNewCache = 1; - - switch (useNewCache) { - case 0: // use the old cache backend - return false; - - case 1: // use the new cache backend - return true; - } - - return true; -} - // static void CacheObserver::SetDiskCacheCapacity(uint32_t aCapacity) @@ -528,8 +493,7 @@ CacheObserver::Observe(nsISupports* aSubject, } if (!strcmp(aTopic, "browser-delayed-startup-finished")) { - uint32_t activeVersion = UseNewCache() ? 1 : 0; - CacheStorageService::CleaupCacheDirectories(sAutoDeleteCacheVersion, activeVersion); + CacheStorageService::CleaupCacheDirectories(); return NS_OK; } diff --git a/netwerk/cache2/CacheObserver.h b/netwerk/cache2/CacheObserver.h index 62e5bbc6ec8a..ac28fd80435a 100644 --- a/netwerk/cache2/CacheObserver.h +++ b/netwerk/cache2/CacheObserver.h @@ -27,7 +27,6 @@ class CacheObserver : public nsIObserver static CacheObserver* Self() { return sSelf; } // Access to preferences - static bool UseNewCache(); static bool UseDiskCache() { return sUseDiskCache; } static bool UseMemoryCache() @@ -86,7 +85,6 @@ private: void StoreHashStatsReported(); void AttachToPreferences(); - static uint32_t sUseNewCache; static bool sUseMemoryCache; static bool sUseDiskCache; static uint32_t sMetadataMemoryLimit; diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index 0f573399933f..80afc3468f8c 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -571,13 +571,11 @@ class CleaupCacheDirectoriesRunnable : public Runnable { public: NS_DECL_NSIRUNNABLE - static bool Post(uint32_t aVersion, uint32_t aActive); + static bool Post(); private: - CleaupCacheDirectoriesRunnable(uint32_t aVersion, uint32_t aActive) + CleaupCacheDirectoriesRunnable() : Runnable("net::CleaupCacheDirectoriesRunnable") - , mVersion(aVersion) - , mActive(aActive) { nsCacheService::GetDiskCacheDirectory(getter_AddRefs(mCache1Dir)); CacheFileIOManager::GetCacheDirectory(getter_AddRefs(mCache2Dir)); @@ -587,7 +585,6 @@ private: } virtual ~CleaupCacheDirectoriesRunnable() {} - uint32_t mVersion, mActive; nsCOMPtr mCache1Dir, mCache2Dir; #if defined(MOZ_WIDGET_ANDROID) nsCOMPtr mCache2Profileless; @@ -595,11 +592,10 @@ private: }; // static -bool CleaupCacheDirectoriesRunnable::Post(uint32_t aVersion, uint32_t aActive) +bool CleaupCacheDirectoriesRunnable::Post() { - // CleaupCacheDirectories is called regardless what cache version is set up to use. // To obtain the cache1 directory we must unfortunately instantiate the old cache - // service despite it may not be used at all... This also initialize nsDeleteDir. + // service despite it may not be used at all... This also initializes nsDeleteDir. nsCOMPtr service = do_GetService(NS_CACHESERVICE_CONTRACTID); if (!service) return false; @@ -609,8 +605,7 @@ bool CleaupCacheDirectoriesRunnable::Post(uint32_t aVersion, uint32_t aActive) if (!thread) return false; - RefPtr r = - new CleaupCacheDirectoriesRunnable(aVersion, aActive); + RefPtr r = new CleaupCacheDirectoriesRunnable(); thread->Dispatch(r, NS_DISPATCH_NORMAL); return true; } @@ -633,22 +628,8 @@ NS_IMETHODIMP CleaupCacheDirectoriesRunnable::Run() } #endif - // Delete the non-active version cache data right now - if (mVersion == mActive) { - return NS_OK; - } - - switch (mVersion) { - case 0: - if (mCache1Dir) { - nsDeleteDir::DeleteDir(mCache1Dir, true, 30000); - } - break; - case 1: - if (mCache2Dir) { - nsDeleteDir::DeleteDir(mCache2Dir, true, 30000); - } - break; + if (mCache1Dir) { + nsDeleteDir::DeleteDir(mCache1Dir, true, 30000); } return NS_OK; @@ -657,11 +638,11 @@ NS_IMETHODIMP CleaupCacheDirectoriesRunnable::Run() } // namespace // static -void CacheStorageService::CleaupCacheDirectories(uint32_t aVersion, uint32_t aActive) +void CacheStorageService::CleaupCacheDirectories() { // Make sure we schedule just once in case CleaupCacheDirectories gets called // multiple times from some reason. - static bool runOnce = CleaupCacheDirectoriesRunnable::Post(aVersion, aActive); + static bool runOnce = CleaupCacheDirectoriesRunnable::Post(); if (!runOnce) { NS_WARNING("Could not start cache trashes cleanup"); } @@ -707,14 +688,8 @@ NS_IMETHODIMP CacheStorageService::MemoryCacheStorage(nsILoadContextInfo *aLoadC NS_ENSURE_ARG(aLoadContextInfo); NS_ENSURE_ARG(_retval); - nsCOMPtr storage; - if (CacheObserver::UseNewCache()) { - storage = new CacheStorage(aLoadContextInfo, false, false, false, false); - } - else { - storage = new _OldStorage(aLoadContextInfo, false, false, false, nullptr); - } - + nsCOMPtr storage = new CacheStorage( + aLoadContextInfo, false, false, false, false); storage.forget(_retval); return NS_OK; } @@ -732,14 +707,8 @@ NS_IMETHODIMP CacheStorageService::DiskCacheStorage(nsILoadContextInfo *aLoadCon // in memory. bool useDisk = CacheObserver::UseDiskCache(); - nsCOMPtr storage; - if (CacheObserver::UseNewCache()) { - storage = new CacheStorage(aLoadContextInfo, useDisk, aLookupAppCache, false /* size limit */, false /* don't pin */); - } - else { - storage = new _OldStorage(aLoadContextInfo, useDisk, aLookupAppCache, false, nullptr); - } - + nsCOMPtr storage = new CacheStorage( + aLoadContextInfo, useDisk, aLookupAppCache, false /* size limit */, false /* don't pin */); storage.forget(_retval); return NS_OK; } @@ -750,10 +719,6 @@ NS_IMETHODIMP CacheStorageService::PinningCacheStorage(nsILoadContextInfo *aLoad NS_ENSURE_ARG(aLoadContextInfo); NS_ENSURE_ARG(_retval); - if (!CacheObserver::UseNewCache()) { - return NS_ERROR_NOT_IMPLEMENTED; - } - // When disk cache is disabled don't pretend we cache. if (!CacheObserver::UseDiskCache()) { return NS_ERROR_NOT_AVAILABLE; @@ -773,14 +738,9 @@ NS_IMETHODIMP CacheStorageService::AppCacheStorage(nsILoadContextInfo *aLoadCont NS_ENSURE_ARG(_retval); nsCOMPtr storage; - if (CacheObserver::UseNewCache()) { - // Using classification since cl believes we want to instantiate this method - // having the same name as the desired class... - storage = new mozilla::net::AppCacheStorage(aLoadContextInfo, aApplicationCache); - } - else { - storage = new _OldStorage(aLoadContextInfo, true, false, true, aApplicationCache); - } + // Using classification since cl believes we want to instantiate this method + // having the same name as the desired class... + storage = new mozilla::net::AppCacheStorage(aLoadContextInfo, aApplicationCache); storage.forget(_retval); return NS_OK; @@ -792,14 +752,8 @@ NS_IMETHODIMP CacheStorageService::SynthesizedCacheStorage(nsILoadContextInfo *a NS_ENSURE_ARG(aLoadContextInfo); NS_ENSURE_ARG(_retval); - nsCOMPtr storage; - if (CacheObserver::UseNewCache()) { - storage = new CacheStorage(aLoadContextInfo, false, false, true /* skip size checks for synthesized cache */, false /* no pinning */); - } - else { - storage = new _OldStorage(aLoadContextInfo, false, false, false, nullptr); - } - + nsCOMPtr storage = new CacheStorage( + aLoadContextInfo, false, false, true /* skip size checks for synthesized cache */, false /* no pinning */); storage.forget(_retval); return NS_OK; } @@ -808,45 +762,34 @@ NS_IMETHODIMP CacheStorageService::Clear() { nsresult rv; - if (CacheObserver::UseNewCache()) { - // Tell the index to block notification to AsyncGetDiskConsumption. - // Will be allowed again from CacheFileContextEvictor::EvictEntries() - // when all the context have been removed from disk. - CacheIndex::OnAsyncEviction(true); + // Tell the index to block notification to AsyncGetDiskConsumption. + // Will be allowed again from CacheFileContextEvictor::EvictEntries() + // when all the context have been removed from disk. + CacheIndex::OnAsyncEviction(true); - { - mozilla::MutexAutoLock lock(mLock); + mozilla::MutexAutoLock lock(mLock); - { - mozilla::MutexAutoLock forcedValidEntriesLock(mForcedValidEntriesLock); - mForcedValidEntries.Clear(); - } - - NS_ENSURE_TRUE(!mShutdown, NS_ERROR_NOT_INITIALIZED); - - nsTArray keys; - for (auto iter = sGlobalEntryTables->Iter(); !iter.Done(); iter.Next()) { - keys.AppendElement(iter.Key()); - } - - for (uint32_t i = 0; i < keys.Length(); ++i) { - DoomStorageEntries(keys[i], nullptr, true, false, nullptr); - } - - // Passing null as a load info means to evict all contexts. - // EvictByContext() respects the entry pinning. EvictAll() does not. - rv = CacheFileIOManager::EvictByContext(nullptr, false); - NS_ENSURE_SUCCESS(rv, rv); - } - } else { - nsCOMPtr serv = - do_GetService(NS_CACHESERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - rv = serv->EvictEntries(nsICache::STORE_ANYWHERE); - NS_ENSURE_SUCCESS(rv, rv); + { + mozilla::MutexAutoLock forcedValidEntriesLock(mForcedValidEntriesLock); + mForcedValidEntries.Clear(); } + NS_ENSURE_TRUE(!mShutdown, NS_ERROR_NOT_INITIALIZED); + + nsTArray keys; + for (auto iter = sGlobalEntryTables->Iter(); !iter.Done(); iter.Next()) { + keys.AppendElement(iter.Key()); + } + + for (uint32_t i = 0; i < keys.Length(); ++i) { + DoomStorageEntries(keys[i], nullptr, true, false, nullptr); + } + + // Passing null as a load info means to evict all contexts. + // EvictByContext() respects the entry pinning. EvictAll() does not. + rv = CacheFileIOManager::EvictByContext(nullptr, false); + NS_ENSURE_SUCCESS(rv, rv); + return NS_OK; } @@ -907,13 +850,8 @@ NS_IMETHODIMP CacheStorageService::AsyncGetDiskConsumption( nsresult rv; - if (CacheObserver::UseNewCache()) { - rv = CacheIndex::AsyncGetDiskConsumption(aObserver); - NS_ENSURE_SUCCESS(rv, rv); - } else { - rv = _OldGetDiskConsumption::Get(aObserver); - NS_ENSURE_SUCCESS(rv, rv); - } + rv = CacheIndex::AsyncGetDiskConsumption(aObserver); + NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } @@ -922,20 +860,8 @@ NS_IMETHODIMP CacheStorageService::GetIoTarget(nsIEventTarget** aEventTarget) { NS_ENSURE_ARG(aEventTarget); - if (CacheObserver::UseNewCache()) { - nsCOMPtr ioTarget = CacheFileIOManager::IOTarget(); - ioTarget.forget(aEventTarget); - } - else { - nsresult rv; - - nsCOMPtr serv = - do_GetService(NS_CACHESERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - rv = serv->GetCacheIOTarget(aEventTarget); - NS_ENSURE_SUCCESS(rv, rv); - } + nsCOMPtr ioTarget = CacheFileIOManager::IOTarget(); + ioTarget.forget(aEventTarget); return NS_OK; } diff --git a/netwerk/cache2/CacheStorageService.h b/netwerk/cache2/CacheStorageService.h index adb9390ab198..0ec6349456a0 100644 --- a/netwerk/cache2/CacheStorageService.h +++ b/netwerk/cache2/CacheStorageService.h @@ -85,8 +85,8 @@ public: void DropPrivateBrowsingEntries(); // Takes care of deleting any pending trashes for both cache1 and cache2 - // as well as the cache directory of an inactive cache version when requested. - static void CleaupCacheDirectories(uint32_t aVersion, uint32_t aActive); + // as well as old cache directory. + static void CleaupCacheDirectories(); static CacheStorageService* Self() { return sSelf; } static nsISupports* SelfISupports() { return static_cast(Self()); } diff --git a/netwerk/protocol/about/nsAboutCache.cpp b/netwerk/protocol/about/nsAboutCache.cpp index eab6f0e1310d..deef97c9affa 100644 --- a/netwerk/protocol/about/nsAboutCache.cpp +++ b/netwerk/protocol/about/nsAboutCache.cpp @@ -105,16 +105,14 @@ nsAboutCache::Channel::Init(nsIURI* aURI, nsILoadInfo* aLoadInfo) "\n" ); - if (CacheObserver::UseNewCache()) { - // Visit scoping by browser and appid is not implemented for - // the old cache, simply don't add these controls. - // The appid/inbrowser entries are already mixed in the default - // view anyway. - mBuffer.AppendLiteral( - "\n" - "\n" - ); - } + // Visit scoping by browser and appid is not implemented for + // the old cache, simply don't add these controls. + // The appid/inbrowser entries are already mixed in the default + // view anyway. + mBuffer.AppendLiteral( + "\n" + "\n" + ); mBuffer.AppendLiteral( "\n" diff --git a/netwerk/protocol/about/nsAboutCacheEntry.cpp b/netwerk/protocol/about/nsAboutCacheEntry.cpp index aec5db8cfd8c..49bd7a80b6bc 100644 --- a/netwerk/protocol/about/nsAboutCacheEntry.cpp +++ b/netwerk/protocol/about/nsAboutCacheEntry.cpp @@ -188,14 +188,6 @@ nsAboutCacheEntry::Channel::OpenCacheEntry(nsIURI *uri) mEnhanceId, getter_AddRefs(mCacheURI)); if (NS_FAILED(rv)) return rv; - if (!CacheObserver::UseNewCache() && - mLoadInfo->IsPrivate() && - mStorageName.EqualsLiteral("disk")) { - // The cache v1 is storing all private entries in the memory-only - // cache, so it would not be found in the v1 disk cache. - mStorageName = NS_LITERAL_CSTRING("memory"); - } - return OpenCacheEntry(); } @@ -307,20 +299,6 @@ nsAboutCacheEntry::Channel::OnCacheEntryAvailable(nsICacheEntry *entry, mWaitingForData = false; if (entry) { rv = WriteCacheEntryDescription(entry); - } else if (!CacheObserver::UseNewCache() && - !mLoadInfo->IsPrivate() && - mStorageName.EqualsLiteral("memory")) { - // If we were not able to find the entry in the memory storage - // try again in the disk storage. - // This is a workaround for cache v1: when an originally disk - // cache entry is recreated as memory-only, it's clientID doesn't - // change and we cannot find it in "HTTP-memory-only" session. - // "Disk" cache storage looks at "HTTP". - mStorageName = NS_LITERAL_CSTRING("disk"); - rv = OpenCacheEntry(); - if (NS_SUCCEEDED(rv)) { - return NS_OK; - } } else { rv = WriteCacheEntryUnavailable(); } diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 32f0550979ef..12d3d1c05c88 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -156,17 +156,12 @@ enum CacheDisposition { void AccumulateCacheHitTelemetry(CacheDisposition hitOrMiss) { - if (!CacheObserver::UseNewCache()) { - Telemetry::Accumulate(Telemetry::HTTP_CACHE_DISPOSITION_2, hitOrMiss); - } - else { - Telemetry::Accumulate(Telemetry::HTTP_CACHE_DISPOSITION_2_V2, hitOrMiss); + Telemetry::Accumulate(Telemetry::HTTP_CACHE_DISPOSITION_2_V2, hitOrMiss); - int32_t experiment = CacheObserver::HalfLifeExperiment(); - if (experiment > 0 && hitOrMiss == kCacheMissed) { - Telemetry::Accumulate(Telemetry::HTTP_CACHE_MISS_HALFLIFE_EXPERIMENT_2, - experiment - 1); - } + int32_t experiment = CacheObserver::HalfLifeExperiment(); + if (experiment > 0 && hitOrMiss == kCacheMissed) { + Telemetry::Accumulate(Telemetry::HTTP_CACHE_MISS_HALFLIFE_EXPERIMENT_2, + experiment - 1); } } @@ -5534,27 +5529,11 @@ nsHttpChannel::InstallCacheListener(int64_t offset) do_CreateInstance(kStreamListenerTeeCID, &rv); if (NS_FAILED(rv)) return rv; - nsCOMPtr cacheIOTarget; - if (!CacheObserver::UseNewCache()) { - nsCOMPtr serv(services::GetCacheStorageService()); - if (!serv) { - return NS_ERROR_NOT_AVAILABLE; - } - - serv->GetIoTarget(getter_AddRefs(cacheIOTarget)); - } - - if (!cacheIOTarget) { - LOG(("nsHttpChannel::InstallCacheListener sync tee %p rv=%" PRIx32 - " cacheIOTarget=%p", - tee.get(), static_cast(rv), cacheIOTarget.get())); - rv = tee->Init(mListener, out, nullptr); - } else { - LOG(("nsHttpChannel::InstallCacheListener async tee %p", tee.get())); - rv = tee->InitAsync(mListener, cacheIOTarget, out, nullptr); - } - + LOG(("nsHttpChannel::InstallCacheListener sync tee %p rv=%" PRIx32, + tee.get(), static_cast(rv))); + rv = tee->Init(mListener, out, nullptr); if (NS_FAILED(rv)) return rv; + mListener = tee; return NS_OK; } diff --git a/netwerk/test/unit/head_cache.js b/netwerk/test/unit/head_cache.js index e43a1ef0765a..833c531ce880 100644 --- a/netwerk/test/unit/head_cache.js +++ b/netwerk/test/unit/head_cache.js @@ -97,7 +97,7 @@ function asyncOpenCacheEntry(key, where, flags, lci, callback, appcache) function syncWithCacheIOThread(callback, force) { - if (!newCacheBackEndUsed() || force) { + if (force) { asyncOpenCacheEntry( "http://nonexistententry/", "disk", Ci.nsICacheStorage.OPEN_READONLY, null, function(status, entry) { diff --git a/netwerk/test/unit/head_cache2.js b/netwerk/test/unit/head_cache2.js index 79ad1c471331..361e6c2f4c81 100644 --- a/netwerk/test/unit/head_cache2.js +++ b/netwerk/test/unit/head_cache2.js @@ -3,16 +3,6 @@ var Ci = Components.interfaces; var Cu = Components.utils; var Cr = Components.results; -function newCacheBackEndUsed() -{ - var cache1srv = Components.classes["@mozilla.org/network/cache-service;1"] - .getService(Components.interfaces.nsICacheService); - var cache2srv = Components.classes["@mozilla.org/netwerk/cache-storage-service;1"] - .getService(Components.interfaces.nsICacheStorageService); - - return cache1srv.cacheIOTarget != cache2srv.ioTarget; -} - var callbacks = new Array(); // Expect an existing entry @@ -133,17 +123,15 @@ OpenCallback.prototype = if (this.behavior & COMPLETE) { LOG_C2(this, "onCacheEntryCheck DONE, return RECHECK_AFTER_WRITE_FINISHED"); - if (newCacheBackEndUsed()) { - // Specific to the new backend because of concurrent read/write: - // when a consumer returns RECHECK_AFTER_WRITE_FINISHED from onCacheEntryCheck - // the cache calls this callback again after the entry write has finished. - // This gives the consumer a chance to recheck completeness of the entry - // again. - // Thus, we reset state as onCheck would have never been called. - this.onCheckPassed = false; - // Don't return RECHECK_AFTER_WRITE_FINISHED on second call of onCacheEntryCheck. - this.behavior &= ~COMPLETE; - } + // Specific to the new backend because of concurrent read/write: + // when a consumer returns RECHECK_AFTER_WRITE_FINISHED from onCacheEntryCheck + // the cache calls this callback again after the entry write has finished. + // This gives the consumer a chance to recheck completeness of the entry + // again. + // Thus, we reset state as onCheck would have never been called. + this.onCheckPassed = false; + // Don't return RECHECK_AFTER_WRITE_FINISHED on second call of onCacheEntryCheck. + this.behavior &= ~COMPLETE; return Ci.nsICacheEntryOpenCallback.RECHECK_AFTER_WRITE_FINISHED; } @@ -310,10 +298,7 @@ VisitCallback.prototype = { LOG_C2(this, "onCacheStorageInfo: num=" + num + ", size=" + consumption); do_check_eq(this.num, num); - if (newCacheBackEndUsed()) { - // Consumption is as expected only in the new backend - do_check_eq(this.consumption, consumption); - } + do_check_eq(this.consumption, consumption); if (!this.entries) this.notify(); }, diff --git a/netwerk/test/unit/test_bug482934.js b/netwerk/test/unit/test_bug482934.js index a4fe7176f359..e6ff5afe1c50 100644 --- a/netwerk/test/unit/test_bug482934.js +++ b/netwerk/test/unit/test_bug482934.js @@ -75,11 +75,6 @@ function run_test() do_get_profile(); evict_cache_entries(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since it depends on the new APIs."); - return; - } - do_test_pending(); cache_storage = getCacheStorage("disk"); diff --git a/netwerk/test/unit/test_cache-control_request.js b/netwerk/test/unit/test_cache-control_request.js index 10f2f2d045df..1b2e8f5159c1 100644 --- a/netwerk/test/unit/test_cache-control_request.js +++ b/netwerk/test/unit/test_cache-control_request.js @@ -86,11 +86,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since it depends on the new APIs."); - return; - } - do_test_pending(); Services.prefs.setBoolPref("network.http.rcwn.enabled", false); diff --git a/netwerk/test/unit/test_cache2-01e-basic-bypass-if-busy.js b/netwerk/test/unit/test_cache2-01e-basic-bypass-if-busy.js index 156add50e1fd..3f5f9bf00db2 100644 --- a/netwerk/test/unit/test_cache2-01e-basic-bypass-if-busy.js +++ b/netwerk/test/unit/test_cache2-01e-basic-bypass-if-busy.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - // Open for write, delay the actual write asyncOpenCacheEntry("http://a/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, new OpenCallback(NEW|DONTFILL, "a1m", "a1d", function(entry) { diff --git a/netwerk/test/unit/test_cache2-01f-basic-openTruncate.js b/netwerk/test/unit/test_cache2-01f-basic-openTruncate.js index d1ef54b5fc76..45fa4076575a 100644 --- a/netwerk/test/unit/test_cache2-01f-basic-openTruncate.js +++ b/netwerk/test/unit/test_cache2-01f-basic-openTruncate.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - var storage = getCacheStorage("disk"); var entry = storage.openTruncate(createURI("http://new1/"), ""); do_check_true(!!entry); diff --git a/netwerk/test/unit/test_cache2-05-visit.js b/netwerk/test/unit/test_cache2-05-visit.js index 550162271018..c88370ac2eda 100644 --- a/netwerk/test/unit/test_cache2-05-visit.js +++ b/netwerk/test/unit/test_cache2-05-visit.js @@ -13,9 +13,7 @@ function run_test() do_execute_soon(function() { syncWithCacheIOThread(function() { - var expectedConsumption = newCacheBackEndUsed() - ? 4096 - : 48; + var expectedConsumption = 4096; storage.asyncVisitStorage( // Test should store 4 entries @@ -32,7 +30,7 @@ function run_test() ); }); }); - }, !newCacheBackEndUsed()); + }); asyncOpenCacheEntry("http://a/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, new OpenCallback(NEW, "a1m", "a1d", function(entry) { diff --git a/netwerk/test/unit/test_cache2-07-visit-memory.js b/netwerk/test/unit/test_cache2-07-visit-memory.js index 03b5aba80a92..b0a8cd0baa67 100644 --- a/netwerk/test/unit/test_cache2-07-visit-memory.js +++ b/netwerk/test/unit/test_cache2-07-visit-memory.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - // Add entry to the memory storage var mc = new MultipleCallbacks(5, function() { // Check it's there by visiting the storage diff --git a/netwerk/test/unit/test_cache2-07a-open-memory.js b/netwerk/test/unit/test_cache2-07a-open-memory.js index 1018a4cbaad6..2745ea747ba0 100644 --- a/netwerk/test/unit/test_cache2-07a-open-memory.js +++ b/netwerk/test/unit/test_cache2-07a-open-memory.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - // First check how behaves the memory storage. asyncOpenCacheEntry("http://mem-first/", "memory", Ci.nsICacheStorage.OPEN_NORMALLY, null, diff --git a/netwerk/test/unit/test_cache2-10b-evict-direct-immediate.js b/netwerk/test/unit/test_cache2-10b-evict-direct-immediate.js index 0f9048db1b98..6e9ff468a107 100644 --- a/netwerk/test/unit/test_cache2-10b-evict-direct-immediate.js +++ b/netwerk/test/unit/test_cache2-10b-evict-direct-immediate.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - asyncOpenCacheEntry("http://b/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, new OpenCallback(NEW|DOOMED, "b1m", "b1d", function(entry) { entry.asyncDoom( diff --git a/netwerk/test/unit/test_cache2-11-evict-memory.js b/netwerk/test/unit/test_cache2-11-evict-memory.js index 90eced7de198..f341a0dbc578 100644 --- a/netwerk/test/unit/test_cache2-11-evict-memory.js +++ b/netwerk/test/unit/test_cache2-11-evict-memory.js @@ -10,9 +10,7 @@ function run_test() new VisitCallback(0, 0, [], function() { var storage = getCacheStorage("disk"); - var expectedConsumption = newCacheBackEndUsed() - ? 2048 - : 24; + var expectedConsumption = 2048; storage.asyncVisitStorage( new VisitCallback(2, expectedConsumption, ["http://a/", "http://b/"], function() { @@ -25,7 +23,7 @@ function run_test() ); }) ); - }, !newCacheBackEndUsed()); + }); asyncOpenCacheEntry("http://mem1/", "memory", Ci.nsICacheStorage.OPEN_NORMALLY, null, new OpenCallback(NEW, "m2m", "m2d", function(entry) { diff --git a/netwerk/test/unit/test_cache2-12-evict-disk.js b/netwerk/test/unit/test_cache2-12-evict-disk.js index 0ce7ec084450..8b1333db3e84 100644 --- a/netwerk/test/unit/test_cache2-12-evict-disk.js +++ b/netwerk/test/unit/test_cache2-12-evict-disk.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - var mc = new MultipleCallbacks(3, function() { var storage = getCacheStorage("disk"); storage.asyncEvictStorage( @@ -25,7 +20,7 @@ function run_test() ); }) ); - }, !newCacheBackEndUsed()); + }); asyncOpenCacheEntry("http://mem1/", "memory", Ci.nsICacheStorage.OPEN_NORMALLY, null, new OpenCallback(NEW, "m2m", "m2d", function(entry) { diff --git a/netwerk/test/unit/test_cache2-14b-concurent-readers-complete.js b/netwerk/test/unit/test_cache2-14b-concurent-readers-complete.js index c5ceb99a0950..f044854a8d9e 100644 --- a/netwerk/test/unit/test_cache2-14b-concurent-readers-complete.js +++ b/netwerk/test/unit/test_cache2-14b-concurent-readers-complete.js @@ -17,7 +17,7 @@ function run_test() new OpenCallback(NORMAL|COMPLETE|NOTIFYBEFOREREAD, "x1m", "x1d", function(entry, beforeReading) { if (beforeReading) { ++order; - do_check_eq(order, newCacheBackEndUsed() ? 3 : 1); + do_check_eq(order, 3); } else { mc.fired(); } @@ -27,7 +27,7 @@ function run_test() new OpenCallback(NORMAL|NOTIFYBEFOREREAD, "x1m", "x1d", function(entry, beforeReading) { if (beforeReading) { ++order; - do_check_eq(order, newCacheBackEndUsed() ? 1 : 2); + do_check_eq(order, 1); } else { mc.fired(); } @@ -37,7 +37,7 @@ function run_test() new OpenCallback(NORMAL|NOTIFYBEFOREREAD, "x1m", "x1d", function(entry, beforeReading) { if (beforeReading) { ++order; - do_check_eq(order, newCacheBackEndUsed() ? 2 : 3); + do_check_eq(order, 2); } else { mc.fired(); } diff --git a/netwerk/test/unit/test_cache2-16-conditional-200.js b/netwerk/test/unit/test_cache2-16-conditional-200.js index 601cca97e9b3..ce79236af01a 100644 --- a/netwerk/test/unit/test_cache2-16-conditional-200.js +++ b/netwerk/test/unit/test_cache2-16-conditional-200.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - // Open for write, write asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, new OpenCallback(NEW, "21m", "21d", function(entry) { diff --git a/netwerk/test/unit/test_cache2-18-not-valid.js b/netwerk/test/unit/test_cache2-18-not-valid.js index c83a78c7af07..86d42b6f0dbc 100644 --- a/netwerk/test/unit/test_cache2-18-not-valid.js +++ b/netwerk/test/unit/test_cache2-18-not-valid.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - // Open for write, write but expect it to fail, since other callback will recreate (and doom) // the first entry before it opens output stream (note: in case of problems the DOOMED flag // can be removed, it is not the test failure when opening the output stream on recreated entry. diff --git a/netwerk/test/unit/test_cache2-19-range-206.js b/netwerk/test/unit/test_cache2-19-range-206.js index ceb782d4e71a..0139133eff48 100644 --- a/netwerk/test/unit/test_cache2-19-range-206.js +++ b/netwerk/test/unit/test_cache2-19-range-206.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - // Open for write, write asyncOpenCacheEntry("http://r206/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, new OpenCallback(NEW, "206m", "206part1-", function(entry) { diff --git a/netwerk/test/unit/test_cache2-20-range-200.js b/netwerk/test/unit/test_cache2-20-range-200.js index 349dd343ee48..15c1488d0f21 100644 --- a/netwerk/test/unit/test_cache2-20-range-200.js +++ b/netwerk/test/unit/test_cache2-20-range-200.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - // Open for write, write asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, new OpenCallback(NEW, "200m1", "200part1a-", function(entry) { diff --git a/netwerk/test/unit/test_cache2-21-anon-storage.js b/netwerk/test/unit/test_cache2-21-anon-storage.js index 6f325077d850..4a9bfbf7612e 100644 --- a/netwerk/test/unit/test_cache2-21-anon-storage.js +++ b/netwerk/test/unit/test_cache2-21-anon-storage.js @@ -4,11 +4,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - // Create and check an entry anon disk storage asyncOpenCacheEntry("http://anon1/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, LoadContextInfo.anonymous, new OpenCallback(NEW, "an1", "an1", function(entry) { diff --git a/netwerk/test/unit/test_cache2-22-anon-visit.js b/netwerk/test/unit/test_cache2-22-anon-visit.js index bc8b15822b71..4f5de0823e12 100644 --- a/netwerk/test/unit/test_cache2-22-anon-visit.js +++ b/netwerk/test/unit/test_cache2-22-anon-visit.js @@ -4,8 +4,7 @@ function run_test() { do_get_profile(); - function checkNewBackEnd() - { + var mc = new MultipleCallbacks(2, function() { var storage = getCacheStorage("disk", LoadContextInfo.default); storage.asyncVisitStorage( new VisitCallback(1, 1024, ["http://an2/"], function() { @@ -19,28 +18,8 @@ function run_test() }), true ); - } + }); - function checkOldBackEnd() - { - syncWithCacheIOThread(function() { - var storage = getCacheStorage("disk", LoadContextInfo.default); - storage.asyncVisitStorage( - new VisitCallback(2, 24, ["http://an2/"], function() { - storage = getCacheStorage("disk", LoadContextInfo.anonymous); - storage.asyncVisitStorage( - new VisitCallback(0, 0, ["http://an2/"], function() { - finish_cache2_test(); - }), - true - ); - }), - true - ); - }); - } - - var mc = new MultipleCallbacks(2, newCacheBackEndUsed() ? checkNewBackEnd : checkOldBackEnd, !newCacheBackEndUsed()); asyncOpenCacheEntry("http://an2/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, LoadContextInfo.default, new OpenCallback(NEW|WAITFORWRITE, "an2", "an2", function(entry) { diff --git a/netwerk/test/unit/test_cache2-23-read-over-chunk.js b/netwerk/test/unit/test_cache2-23-read-over-chunk.js index 92959645ddb3..2213b3976357 100644 --- a/netwerk/test/unit/test_cache2-23-read-over-chunk.js +++ b/netwerk/test/unit/test_cache2-23-read-over-chunk.js @@ -4,11 +4,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test checks only cache2 specific behavior."); - return; - } - const kChunkSize = (256 * 1024); var payload = ""; diff --git a/netwerk/test/unit/test_cache2-24-exists.js b/netwerk/test/unit/test_cache2-24-exists.js index fee8a2ee75f1..6000bffd9ad9 100644 --- a/netwerk/test/unit/test_cache2-24-exists.js +++ b/netwerk/test/unit/test_cache2-24-exists.js @@ -4,11 +4,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test checks only cache2 specific behavior."); - return; - } - var mc = new MultipleCallbacks(2, function() { var mem = getCacheStorage("memory"); var disk = getCacheStorage("disk"); diff --git a/netwerk/test/unit/test_cache2-25-chunk-memory-limit.js b/netwerk/test/unit/test_cache2-25-chunk-memory-limit.js index 0999dc8d2f33..2d5326a80802 100644 --- a/netwerk/test/unit/test_cache2-25-chunk-memory-limit.js +++ b/netwerk/test/unit/test_cache2-25-chunk-memory-limit.js @@ -18,11 +18,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - var prefBranch = Cc["@mozilla.org/preferences-service;1"]. getService(Ci.nsIPrefBranch); diff --git a/netwerk/test/unit/test_cache2-26-no-outputstream-open.js b/netwerk/test/unit/test_cache2-26-no-outputstream-open.js index f54bc19a5c85..2de9529f8170 100644 --- a/netwerk/test/unit/test_cache2-26-no-outputstream-open.js +++ b/netwerk/test/unit/test_cache2-26-no-outputstream-open.js @@ -2,11 +2,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - // Open for write, but never write and never mark valid asyncOpenCacheEntry("http://no-data/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, new OpenCallback(NEW|METAONLY|DONTSETVALID|WAITFORWRITE, "meta", "", function(entry) { diff --git a/netwerk/test/unit/test_cache2-27-force-valid-for.js b/netwerk/test/unit/test_cache2-27-force-valid-for.js index c3663751dfee..811d3a2dc434 100644 --- a/netwerk/test/unit/test_cache2-27-force-valid-for.js +++ b/netwerk/test/unit/test_cache2-27-force-valid-for.js @@ -4,11 +4,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test checks only cache2 specific behavior."); - return; - } - var mc = new MultipleCallbacks(2, function() { finish_cache2_test(); }); diff --git a/netwerk/test/unit/test_cache2-29d-concurrent_read_half-corrupted-206.js b/netwerk/test/unit/test_cache2-29d-concurrent_read_half-corrupted-206.js index 37ed03869782..65fe326d59ce 100644 --- a/netwerk/test/unit/test_cache2-29d-concurrent_read_half-corrupted-206.js +++ b/netwerk/test/unit/test_cache2-29d-concurrent_read_half-corrupted-206.js @@ -65,11 +65,6 @@ function run_test() do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - Services.prefs.setIntPref("browser.cache.disk.max_entry_size", 1); Services.prefs.setBoolPref("network.http.rcwn.enabled", false); diff --git a/netwerk/test/unit/test_cache2-29e-concurrent_read_half-non-206-response.js b/netwerk/test/unit/test_cache2-29e-concurrent_read_half-non-206-response.js index 7c3ae2f9e8ec..1dbaa0a3cc10 100644 --- a/netwerk/test/unit/test_cache2-29e-concurrent_read_half-non-206-response.js +++ b/netwerk/test/unit/test_cache2-29e-concurrent_read_half-non-206-response.js @@ -60,11 +60,6 @@ function run_test() do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); - return; - } - Services.prefs.setIntPref("browser.cache.disk.max_entry_size", 1); Services.prefs.setBoolPref("network.http.rcwn.enabled", false); diff --git a/netwerk/test/unit/test_cache2-30a-entry-pinning.js b/netwerk/test/unit/test_cache2-30a-entry-pinning.js index 3a5db421aa96..ace537884f5c 100644 --- a/netwerk/test/unit/test_cache2-30a-entry-pinning.js +++ b/netwerk/test/unit/test_cache2-30a-entry-pinning.js @@ -1,10 +1,6 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test checks only cache2 specific behavior."); - return; - } // Open for write, write asyncOpenCacheEntry("http://a/", "pin", Ci.nsICacheStorage.OPEN_TRUNCATE, LoadContextInfo.default, diff --git a/netwerk/test/unit/test_cache2-30b-pinning-storage-clear.js b/netwerk/test/unit/test_cache2-30b-pinning-storage-clear.js index a9410ff75723..b723dcd369ff 100644 --- a/netwerk/test/unit/test_cache2-30b-pinning-storage-clear.js +++ b/netwerk/test/unit/test_cache2-30b-pinning-storage-clear.js @@ -1,10 +1,7 @@ function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test checks only cache2 specific behavior."); - return; - } + var lci = LoadContextInfo.default; // Open a pinned entry for write, write diff --git a/netwerk/test/unit/test_cache2-30c-pinning-deferred-doom.js b/netwerk/test/unit/test_cache2-30c-pinning-deferred-doom.js index ff919cc2f291..357a8cc117fe 100644 --- a/netwerk/test/unit/test_cache2-30c-pinning-deferred-doom.js +++ b/netwerk/test/unit/test_cache2-30c-pinning-deferred-doom.js @@ -26,10 +26,6 @@ function log_(msg) { if (true) dump(">>>>>>>>>>>>> " + msg + "\n"); } function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test checks only cache2 specific behavior."); - return; - } var lci = LoadContextInfo.default; var testingInterface = get_cache_service().QueryInterface(Ci.nsICacheTesting); diff --git a/netwerk/test/unit/test_cache2-30d-pinning-WasEvicted-API.js b/netwerk/test/unit/test_cache2-30d-pinning-WasEvicted-API.js index da2630485c5b..04409cf475c2 100644 --- a/netwerk/test/unit/test_cache2-30d-pinning-WasEvicted-API.js +++ b/netwerk/test/unit/test_cache2-30d-pinning-WasEvicted-API.js @@ -22,10 +22,7 @@ function log_(msg) { if (true) dump(">>>>>>>>>>>>> " + msg + "\n"); } function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test checks only cache2 specific behavior."); - return; - } + var lci = LoadContextInfo.default; var testingInterface = get_cache_service().QueryInterface(Ci.nsICacheTesting); do_check_true(testingInterface); diff --git a/netwerk/test/unit/test_cache2-31-visit-all.js b/netwerk/test/unit/test_cache2-31-visit-all.js index 9b86554f774b..d9d9d3a45c6f 100644 --- a/netwerk/test/unit/test_cache2-31-visit-all.js +++ b/netwerk/test/unit/test_cache2-31-visit-all.js @@ -7,10 +7,6 @@ function run_test() LoadContextInfo.custom(false, { userContextId: 3 })]; do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test checks only cache2 specific behavior."); - return; - } var mc = new MultipleCallbacks(8, function() { do_execute_soon(function() { diff --git a/netwerk/test/unit/test_cache_jar.js b/netwerk/test/unit/test_cache_jar.js index 7a66e10ced9e..8dc97b33ba56 100644 --- a/netwerk/test/unit/test_cache_jar.js +++ b/netwerk/test/unit/test_cache_jar.js @@ -89,10 +89,7 @@ async function run_all_tests() { function run_test() { do_get_profile(); - if (!newCacheBackEndUsed()) { - do_check_true(true, "This test checks only cache2 specific behavior."); - return; - } + do_test_pending(); Services.prefs.setBoolPref("network.http.rcwn.enabled", false); diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index f8bffd6df5da..dd2c5e5896ab 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -1981,14 +1981,6 @@ "n_buckets": 50, "description": "HTTP page channel: Open -> first byte of reply received (ms)" }, - "HTTP_PAGE_OPEN_TO_FIRST_FROM_CACHE": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "exponential", - "high": 30000, - "n_buckets": 50, - "description": "HTTP page channel: Open -> cache read start (ms)" - }, "HTTP_PAGE_OPEN_TO_FIRST_FROM_CACHE_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", @@ -1997,14 +1989,6 @@ "n_buckets": 50, "description": "HTTP page channel: Open -> cache read start (ms), [cache2]" }, - "HTTP_PAGE_CACHE_READ_TIME": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "exponential", - "high": 30000, - "n_buckets": 50, - "description": "HTTP page channel: Cache read time (ms)" - }, "HTTP_PAGE_CACHE_READ_TIME_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", @@ -2021,14 +2005,6 @@ "n_buckets": 50, "description": "HTTP page channel: Positive cache validation time (ms)" }, - "HTTP_PAGE_COMPLETE_LOAD": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "exponential", - "high": 30000, - "n_buckets": 50, - "description": "HTTP page channel: Overall load time - all (ms)" - }, "HTTP_PAGE_COMPLETE_LOAD_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", @@ -2037,14 +2013,6 @@ "n_buckets": 50, "description": "HTTP page channel: Overall load time - all (ms) [cache2]" }, - "HTTP_PAGE_COMPLETE_LOAD_CACHED": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "exponential", - "high": 30000, - "n_buckets": 50, - "description": "HTTP page channel: Overall load time - cache hits (ms)" - }, "HTTP_PAGE_COMPLETE_LOAD_CACHED_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", @@ -2053,14 +2021,6 @@ "n_buckets": 50, "description": "HTTP page channel: Overall load time - cache hits (ms) [cache2]" }, - "HTTP_PAGE_COMPLETE_LOAD_NET": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "exponential", - "high": 30000, - "n_buckets": 50, - "description": "HTTP page channel: Overall load time - network (ms)" - }, "HTTP_PAGE_COMPLETE_LOAD_NET_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", @@ -2129,14 +2089,6 @@ "n_buckets": 50, "description": "HTTP subitem channel: Open -> first byte of reply received (ms)" }, - "HTTP_SUB_OPEN_TO_FIRST_FROM_CACHE": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "exponential", - "high": 30000, - "n_buckets": 50, - "description": "HTTP subitem channel: Open -> cache read start (ms)" - }, "HTTP_SUB_OPEN_TO_FIRST_FROM_CACHE_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", @@ -2145,14 +2097,6 @@ "n_buckets": 50, "description": "HTTP subitem channel: Open -> cache read start (ms) [cache2]" }, - "HTTP_SUB_CACHE_READ_TIME": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "exponential", - "high": 30000, - "n_buckets": 50, - "description": "HTTP subitem channel: Cache read time (ms)" - }, "HTTP_SUB_CACHE_READ_TIME_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", @@ -2169,14 +2113,6 @@ "n_buckets": 50, "description": "HTTP subitem channel: Positive cache validation time (ms)" }, - "HTTP_SUB_COMPLETE_LOAD": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "exponential", - "high": 30000, - "n_buckets": 50, - "description": "HTTP subitem channel: Overall load time - all (ms)" - }, "HTTP_SUB_COMPLETE_LOAD_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", @@ -2185,14 +2121,6 @@ "n_buckets": 50, "description": "HTTP subitem channel: Overall load time - all (ms) [cache2]" }, - "HTTP_SUB_COMPLETE_LOAD_CACHED": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "exponential", - "high": 30000, - "n_buckets": 50, - "description": "HTTP subitem channel: Overall load time - cache hits (ms)" - }, "HTTP_SUB_COMPLETE_LOAD_CACHED_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", @@ -2201,14 +2129,6 @@ "n_buckets": 50, "description": "HTTP subitem channel: Overall load time - cache hits (ms) [cache2]" }, - "HTTP_SUB_COMPLETE_LOAD_NET": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "exponential", - "high": 30000, - "n_buckets": 50, - "description": "HTTP subitem channel: Overall load time - network (ms)" - }, "HTTP_SUB_COMPLETE_LOAD_NET_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", @@ -3007,13 +2927,6 @@ "kind": "boolean", "description": "Fraction of sockets that used a nsConnectionEntry with history - size 300." }, - "HTTP_CACHE_DISPOSITION_2": { - "record_in_processes": ["main", "content"], - "expires_in_version": "never", - "kind": "enumerated", - "n_values": 5, - "description": "HTTP Cache Hit, Reval, Failed-Reval, Miss" - }, "HTTP_CACHE_DISPOSITION_2_V2": { "record_in_processes": ["main", "content"], "expires_in_version": "never", diff --git a/toolkit/components/telemetry/histogram-whitelists.json b/toolkit/components/telemetry/histogram-whitelists.json index 1c6749df4aca..fb9b231e8266 100644 --- a/toolkit/components/telemetry/histogram-whitelists.json +++ b/toolkit/components/telemetry/histogram-whitelists.json @@ -253,7 +253,6 @@ "HTTPCONNMGR_TOTAL_SPECULATIVE_CONN", "HTTPCONNMGR_UNUSED_SPECULATIVE_CONN", "HTTPCONNMGR_USED_SPECULATIVE_CONN", - "HTTP_CACHE_DISPOSITION_2", "HTTP_CACHE_DISPOSITION_2_V2", "HTTP_CACHE_ENTRY_ALIVE_TIME", "HTTP_CACHE_ENTRY_RELOAD_TIME", @@ -263,18 +262,13 @@ "HTTP_DISK_CACHE_OVERHEAD", "HTTP_KBREAD_PER_CONN", "HTTP_OFFLINE_CACHE_DOCUMENT_LOAD", - "HTTP_PAGE_CACHE_READ_TIME", "HTTP_PAGE_CACHE_READ_TIME_V2", - "HTTP_PAGE_COMPLETE_LOAD", - "HTTP_PAGE_COMPLETE_LOAD_CACHED", "HTTP_PAGE_COMPLETE_LOAD_CACHED_V2", - "HTTP_PAGE_COMPLETE_LOAD_NET", "HTTP_PAGE_COMPLETE_LOAD_NET_V2", "HTTP_PAGE_COMPLETE_LOAD_V2", "HTTP_PAGE_DNS_ISSUE_TIME", "HTTP_PAGE_DNS_LOOKUP_TIME", "HTTP_PAGE_FIRST_SENT_TO_LAST_RECEIVED", - "HTTP_PAGE_OPEN_TO_FIRST_FROM_CACHE", "HTTP_PAGE_OPEN_TO_FIRST_FROM_CACHE_V2", "HTTP_PAGE_OPEN_TO_FIRST_RECEIVED", "HTTP_PAGE_OPEN_TO_FIRST_SENT", @@ -285,18 +279,13 @@ "HTTP_REQUEST_PER_PAGE_FROM_CACHE", "HTTP_SUBITEM_FIRST_BYTE_LATENCY_TIME", "HTTP_SUBITEM_OPEN_LATENCY_TIME", - "HTTP_SUB_CACHE_READ_TIME", "HTTP_SUB_CACHE_READ_TIME_V2", - "HTTP_SUB_COMPLETE_LOAD", - "HTTP_SUB_COMPLETE_LOAD_CACHED", "HTTP_SUB_COMPLETE_LOAD_CACHED_V2", - "HTTP_SUB_COMPLETE_LOAD_NET", "HTTP_SUB_COMPLETE_LOAD_NET_V2", "HTTP_SUB_COMPLETE_LOAD_V2", "HTTP_SUB_DNS_ISSUE_TIME", "HTTP_SUB_DNS_LOOKUP_TIME", "HTTP_SUB_FIRST_SENT_TO_LAST_RECEIVED", - "HTTP_SUB_OPEN_TO_FIRST_FROM_CACHE", "HTTP_SUB_OPEN_TO_FIRST_FROM_CACHE_V2", "HTTP_SUB_OPEN_TO_FIRST_RECEIVED", "HTTP_SUB_OPEN_TO_FIRST_SENT", @@ -928,7 +917,6 @@ "HTTPCONNMGR_TOTAL_SPECULATIVE_CONN", "HTTPCONNMGR_UNUSED_SPECULATIVE_CONN", "HTTPCONNMGR_USED_SPECULATIVE_CONN", - "HTTP_CACHE_DISPOSITION_2", "HTTP_CACHE_DISPOSITION_2_V2", "HTTP_CACHE_ENTRY_ALIVE_TIME", "HTTP_CACHE_ENTRY_RELOAD_TIME", @@ -939,18 +927,13 @@ "HTTP_DISK_CACHE_OVERHEAD", "HTTP_KBREAD_PER_CONN", "HTTP_OFFLINE_CACHE_DOCUMENT_LOAD", - "HTTP_PAGE_CACHE_READ_TIME", "HTTP_PAGE_CACHE_READ_TIME_V2", - "HTTP_PAGE_COMPLETE_LOAD", - "HTTP_PAGE_COMPLETE_LOAD_CACHED", "HTTP_PAGE_COMPLETE_LOAD_CACHED_V2", - "HTTP_PAGE_COMPLETE_LOAD_NET", "HTTP_PAGE_COMPLETE_LOAD_NET_V2", "HTTP_PAGE_COMPLETE_LOAD_V2", "HTTP_PAGE_DNS_ISSUE_TIME", "HTTP_PAGE_DNS_LOOKUP_TIME", "HTTP_PAGE_FIRST_SENT_TO_LAST_RECEIVED", - "HTTP_PAGE_OPEN_TO_FIRST_FROM_CACHE", "HTTP_PAGE_OPEN_TO_FIRST_FROM_CACHE_V2", "HTTP_PAGE_OPEN_TO_FIRST_RECEIVED", "HTTP_PAGE_OPEN_TO_FIRST_SENT", @@ -963,18 +946,13 @@ "HTTP_SAW_QUIC_ALT_PROTOCOL", "HTTP_SUBITEM_FIRST_BYTE_LATENCY_TIME", "HTTP_SUBITEM_OPEN_LATENCY_TIME", - "HTTP_SUB_CACHE_READ_TIME", "HTTP_SUB_CACHE_READ_TIME_V2", - "HTTP_SUB_COMPLETE_LOAD", - "HTTP_SUB_COMPLETE_LOAD_CACHED", "HTTP_SUB_COMPLETE_LOAD_CACHED_V2", - "HTTP_SUB_COMPLETE_LOAD_NET", "HTTP_SUB_COMPLETE_LOAD_NET_V2", "HTTP_SUB_COMPLETE_LOAD_V2", "HTTP_SUB_DNS_ISSUE_TIME", "HTTP_SUB_DNS_LOOKUP_TIME", "HTTP_SUB_FIRST_SENT_TO_LAST_RECEIVED", - "HTTP_SUB_OPEN_TO_FIRST_FROM_CACHE", "HTTP_SUB_OPEN_TO_FIRST_FROM_CACHE_V2", "HTTP_SUB_OPEN_TO_FIRST_RECEIVED", "HTTP_SUB_OPEN_TO_FIRST_SENT",