Bug 1383215: Part 1 - Don't resolve module URIs to files when already cached. r?mccr8
MozReview-Commit-ID: KBhXhcJkRjp
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -899,59 +899,57 @@ mozJSComponentLoader::ImportInto(const n
nsresult rv;
if (!mInitialized) {
rv = ReallyInit();
NS_ENSURE_SUCCESS(rv, rv);
}
ComponentLoaderInfo info(aLocation);
- rv = info.EnsureResolvedURI();
- NS_ENSURE_SUCCESS(rv, rv);
-
- // get the JAR if there is one
- nsCOMPtr<nsIJARURI> jarURI;
- jarURI = do_QueryInterface(info.ResolvedURI(), &rv);
- nsCOMPtr<nsIFileURL> baseFileURL;
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr<nsIURI> baseURI;
- while (jarURI) {
- jarURI->GetJARFile(getter_AddRefs(baseURI));
- jarURI = do_QueryInterface(baseURI, &rv);
- }
- baseFileURL = do_QueryInterface(baseURI, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
- } else {
- baseFileURL = do_QueryInterface(info.ResolvedURI(), &rv);
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- nsCOMPtr<nsIFile> sourceFile;
- rv = baseFileURL->GetFile(getter_AddRefs(sourceFile));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr<nsIFile> sourceLocalFile;
- sourceLocalFile = do_QueryInterface(sourceFile, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
rv = info.EnsureKey();
NS_ENSURE_SUCCESS(rv, rv);
ModuleEntry* mod;
nsAutoPtr<ModuleEntry> newEntry;
if (!mImports.Get(info.Key(), &mod) && !mInProgressImports.Get(info.Key(), &mod)) {
newEntry = new ModuleEntry(RootingContext::get(callercx));
if (!newEntry)
return NS_ERROR_OUT_OF_MEMORY;
+
+ rv = info.EnsureResolvedURI();
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // get the JAR if there is one
+ nsCOMPtr<nsIJARURI> jarURI;
+ jarURI = do_QueryInterface(info.ResolvedURI(), &rv);
+ nsCOMPtr<nsIFileURL> baseFileURL;
+ if (NS_SUCCEEDED(rv)) {
+ nsCOMPtr<nsIURI> baseURI;
+ while (jarURI) {
+ jarURI->GetJARFile(getter_AddRefs(baseURI));
+ jarURI = do_QueryInterface(baseURI, &rv);
+ }
+ baseFileURL = do_QueryInterface(baseURI, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+ } else {
+ baseFileURL = do_QueryInterface(info.ResolvedURI(), &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ nsCOMPtr<nsIFile> sourceFile;
+ rv = baseFileURL->GetFile(getter_AddRefs(sourceFile));
+ NS_ENSURE_SUCCESS(rv, rv);
+
mInProgressImports.Put(info.Key(), newEntry);
rv = info.EnsureURI();
NS_ENSURE_SUCCESS(rv, rv);
RootedValue exception(callercx);
- rv = ObjectForLocation(info, sourceLocalFile, &newEntry->obj,
+ rv = ObjectForLocation(info, sourceFile, &newEntry->obj,
&newEntry->thisObjectKey,
&newEntry->location, true, &exception);
mInProgressImports.Remove(info.Key());
if (NS_FAILED(rv)) {
if (!exception.isUndefined()) {
// An exception was thrown during compilation. Propagate it