Bug 1383215: Part 3 - Use scache::ResolveURI to resolve module URIs. r?mccr8
Since we now usually load modules from one of the startup caches, we usually
have no need to ever actually create a channel in order to load them.
Resolving the URIs directly is much cheaper in the normal case.
MozReview-Commit-ID: 8W8RMHRnyBa
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -241,18 +241,18 @@ class MOZ_STACK_CLASS ComponentLoaderInf
nullptr, // aLoadGroup
nullptr, // aCallbacks
nsIRequest::LOAD_NORMAL,
mIOService);
}
nsIURI* ResolvedURI() { MOZ_ASSERT(mResolvedURI); return mResolvedURI; }
nsresult EnsureResolvedURI() {
- BEGIN_ENSURE(ResolvedURI, ScriptChannel);
- return mScriptChannel->GetURI(getter_AddRefs(mResolvedURI));
+ BEGIN_ENSURE(ResolvedURI, URI);
+ return ResolveURI(mURI, getter_AddRefs(mResolvedURI));
}
nsAutoCString& Key() { return *mKey; }
nsresult EnsureKey() {
ENSURE_DEPS(ResolvedURI);
mKey.emplace();
return mResolvedURI->GetSpec(*mKey);
}
@@ -608,18 +608,20 @@ mozJSComponentLoader::ObjectForLocation(
// Before compiling the script, first check to see if we have it in
// the startupcache. Note: as a rule, startupcache errors are not fatal
// to loading the script, since we can always slow-load.
bool writeToCache = false;
StartupCache* cache = StartupCache::GetSingleton();
+ aInfo.EnsureResolvedURI();
+
nsAutoCString cachePath(kJSCachePrefix);
- rv = PathifyURI(aInfo.URI(), cachePath);
+ rv = PathifyURI(aInfo.ResolvedURI(), cachePath);
NS_ENSURE_SUCCESS(rv, rv);
script = ScriptPreloader::GetSingleton().GetCachedScript(cx, cachePath);
if (!script && cache) {
ReadCachedScript(cache, cachePath, cx, &script);
}
if (script) {