Bug 1752212 - Part 2: Add loader type to cache key used by nsFrameMessageManager. r=nbp

Differential Revision: https://phabricator.services.mozilla.com/D143575
This commit is contained in:
Tooru Fujisawa 2022-04-13 14:08:07 +00:00
parent 4de0e49a0d
commit a738d66e34

View File

@ -69,6 +69,7 @@
#include "mozilla/dom/MessageManagerCallback.h"
#include "mozilla/dom/ipc/SharedMap.h"
#include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/scache/StartupCacheUtils.h"
#include "nsASCIIMask.h"
#include "nsBaseHashtable.h"
#include "nsCOMPtr.h"
@ -130,6 +131,8 @@ using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::dom::ipc;
static const char kMessageManagerCachePrefix[] = "mm";
nsFrameMessageManager::nsFrameMessageManager(MessageManagerCallback* aCallback,
MessageManagerFlags aFlags)
: mChrome(aFlags & MessageManagerFlags::MM_CHROME),
@ -1272,10 +1275,14 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
RefPtr<JS::Stencil> stencil;
if (useScriptPreloader) {
nsAutoCString cachePath;
rv = scache::PathifyURI(kMessageManagerCachePrefix, uri, cachePath);
NS_ENSURE_SUCCESS(rv, nullptr);
JS::DecodeOptions decodeOptions;
ScriptPreloader::FillDecodeOptionsForCachedStencil(decodeOptions);
stencil = ScriptPreloader::GetChildSingleton().GetCachedStencil(
cx, decodeOptions, url);
cx, decodeOptions, cachePath);
}
if (!stencil) {
@ -1350,7 +1357,10 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
MOZ_ASSERT(stencil);
if (useScriptPreloader) {
ScriptPreloader::GetChildSingleton().NoteStencil(url, url, stencil,
nsAutoCString cachePath;
rv = scache::PathifyURI(kMessageManagerCachePrefix, uri, cachePath);
NS_ENSURE_SUCCESS(rv, nullptr);
ScriptPreloader::GetChildSingleton().NoteStencil(url, cachePath, stencil,
isRunOnce);
}