Bug 1383215: Part 3 - Use scache::ResolveURI to resolve module URIs. r?mccr8 draft
authorKris Maglione <maglione.k@gmail.com>
Fri, 21 Jul 2017 15:42:38 -0700
changeset 613439 21d94c910f5cc4cc199b472f005a18fe9295e71c
parent 613438 2758832556ae4acc1fff9f9947a0a99e3e175041
child 613440 7428c37bef38b4b5d66dc5c72f40b6c709598dcb
push id69800
push usermaglione.k@gmail.com
push dateFri, 21 Jul 2017 23:03:45 +0000
reviewersmccr8
bugs1383215
milestone56.0a1
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
js/xpconnect/loader/mozJSComponentLoader.cpp
--- 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) {