tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 1efe30299a58a5cb960ee5c4b17b11feac7e686d
parent e9679973391ec852d47ca2dcf72cd2f19e379827
Author: Tooru Fujisawa <arai_a@mac.com>
Date:   Tue,  9 Dec 2025 05:11:37 +0000

Bug 2002960 - Part 3: Use nsICacheEntryWriteHandle in LoadedScript. r=nbp

Differential Revision: https://phabricator.services.mozilla.com/D274398

Diffstat:
Mdom/script/ScriptLoader.cpp | 13+++++++------
Mjs/loader/LoadedScript.cpp | 2+-
Mjs/loader/LoadedScript.h | 6+++---
3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp @@ -3714,7 +3714,7 @@ bool ScriptLoader::SaveToDiskCache( // might fail if the stream is already open by another request, in which // case, we just ignore the current one. nsCOMPtr<nsIAsyncOutputStream> output; - nsresult rv = aLoadedScript->mCacheInfo->OpenAlternativeOutputStream( + nsresult rv = aLoadedScript->mCacheEntry->OpenAlternativeOutputStream( BytecodeMimeTypeFor(aLoadedScript), static_cast<int64_t>(aCompressed.length()), getter_AddRefs(output)); if (NS_FAILED(rv)) { @@ -4071,8 +4071,9 @@ nsresult ScriptLoader::OnStreamComplete( aLoader->GetRequest(getter_AddRefs(channelRequest)); nsCOMPtr<nsICacheInfoChannel> cacheInfo = do_QueryInterface(channelRequest); - - if (cacheInfo) { + nsCOMPtr<nsICacheEntryWriteHandle> cacheEntry; + if (cacheInfo && NS_SUCCEEDED(cacheInfo->GetCacheEntryWriteHandle( + getter_AddRefs(cacheEntry)))) { uint64_t id; nsresult rv = cacheInfo->GetCacheEntryId(&id); if (NS_SUCCEEDED(rv)) { @@ -4124,9 +4125,9 @@ nsresult ScriptLoader::OnStreamComplete( } } - aRequest->getLoadedScript()->mCacheInfo = cacheInfo; - LOG(("ScriptLoadRequest (%p): nsICacheInfoChannel = %p", aRequest, - aRequest->getLoadedScript()->mCacheInfo.get())); + aRequest->getLoadedScript()->mCacheEntry = cacheEntry; + LOG(("ScriptLoadRequest (%p): nsICacheEntryWriteHandle = %p", aRequest, + (void*)cacheEntry)); rv = SaveSRIHash(aRequest, aSRIDataVerifier); } diff --git a/js/loader/LoadedScript.cpp b/js/loader/LoadedScript.cpp @@ -42,7 +42,7 @@ NS_INTERFACE_MAP_END // // NOTE: nsIURI doesn't have to be touched here because it cannot be a part // of cycle. -NS_IMPL_CYCLE_COLLECTION(LoadedScript, mFetchOptions, mCacheInfo) +NS_IMPL_CYCLE_COLLECTION(LoadedScript, mFetchOptions, mCacheEntry) NS_IMPL_CYCLE_COLLECTING_ADDREF(LoadedScript) NS_IMPL_CYCLE_COLLECTING_RELEASE(LoadedScript) diff --git a/js/loader/LoadedScript.h b/js/loader/LoadedScript.h @@ -301,10 +301,10 @@ class LoadedScript : public nsIMemoryReporter { // Check the reference to the cache info channel, which is used by the disk // cache. - bool HasDiskCacheReference() const { return !!mCacheInfo; } + bool HasDiskCacheReference() const { return !!mCacheEntry; } // Drop the reference to the cache info channel. - void DropDiskCacheReference() { mCacheInfo = nullptr; } + void DropDiskCacheReference() { mCacheEntry = nullptr; } void DropDiskCacheReferenceAndSRI() { DropDiskCacheReference(); @@ -438,7 +438,7 @@ class LoadedScript : public nsIMemoryReporter { // This field is populated if the cache is enabled and this is either // IsTextSource() or IsCachedStencil(), and it's cleared after saving to the // necko cache, and thus, this field is used only once. - nsCOMPtr<nsICacheInfoChannel> mCacheInfo; + nsCOMPtr<nsICacheEntryWriteHandle> mCacheEntry; }; // Provide accessors for any classes `Derived` which is providing the