diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 5f6ee701fc95..d73f6238399e 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -485,51 +485,6 @@ mozJSComponentLoader::ReallyInit() return NS_OK; } -nsresult -mozJSComponentLoader::FileKey(nsILocalFile* aFile, nsAString &aResult) -{ - nsresult rv = NS_OK; - nsAutoString canonicalPath; - -#if defined(XP_WIN) - nsCOMPtr winFile = do_QueryInterface(aFile, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - winFile->GetCanonicalPath(canonicalPath); -#else - aFile->GetPath(canonicalPath); -#endif - - aResult = NS_LITERAL_STRING("f"); - aResult += canonicalPath; - - return rv; -} - -nsresult -mozJSComponentLoader::JarKey(nsILocalFile* aFile, - const nsACString &aComponentPath, - nsAString &aResult) -{ - nsresult rv = NS_OK; - nsAutoString canonicalPath; - -#if defined(XP_WIN) - nsCOMPtr winFile = do_QueryInterface(aFile, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - winFile->GetCanonicalPath(canonicalPath); -#else - aFile->GetPath(canonicalPath); -#endif - - aResult = NS_LITERAL_STRING("j"); - aResult += canonicalPath; - AppendUTF8toUTF16(aComponentPath, aResult); - - return rv; -} - const mozilla::Module* mozJSComponentLoader::LoadModule(nsILocalFile* aComponentFile) { @@ -541,13 +496,8 @@ mozJSComponentLoader::LoadModule(nsILocalFile* aComponentFile) if (NS_FAILED(rv)) return NULL; - nsAutoString hashstring; - rv = FileKey(aComponentFile, hashstring); - if (NS_FAILED(rv)) - return NULL; - return LoadModuleImpl(aComponentFile, - hashstring, + spec, uri); } @@ -569,19 +519,14 @@ mozJSComponentLoader::LoadModuleFromJAR(nsILocalFile *aJarFile, if (NS_FAILED(rv)) return NULL; - nsAutoString hashstring; - rv = JarKey(aJarFile, aComponentPath, hashstring); - if (NS_FAILED(rv)) - return NULL; - return LoadModuleImpl(aJarFile, - hashstring, + fullSpec, uri); } const mozilla::Module* mozJSComponentLoader::LoadModuleImpl(nsILocalFile* aSourceFile, - nsAString &aKey, + nsACString &aKey, nsIURI* aComponentURI) { nsresult rv; @@ -1041,7 +986,7 @@ mozJSComponentLoader::GlobalForLocation(nsILocalFile *aComponentFile, } /* static */ PLDHashOperator -mozJSComponentLoader::ClearModules(const nsAString& key, ModuleEntry*& entry, void* cx) +mozJSComponentLoader::ClearModules(const nsACString& key, ModuleEntry*& entry, void* cx) { entry->Clear(); return PL_DHASH_REMOVE; @@ -1206,7 +1151,6 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation, nsCOMPtr jarURI; jarURI = do_QueryInterface(resolvedURI, &rv); nsCOMPtr baseFileURL; - nsCAutoString jarEntry; if (NS_SUCCEEDED(rv)) { nsCOMPtr baseURI; rv = jarURI->GetJARFile(getter_AddRefs(baseURI)); @@ -1214,9 +1158,6 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation, baseFileURL = do_QueryInterface(baseURI, &rv); NS_ENSURE_SUCCESS(rv, rv); - - jarURI->GetJAREntry(jarEntry); - NS_ENSURE_SUCCESS(rv, rv); } else { baseFileURL = do_QueryInterface(resolvedURI, &rv); NS_ENSURE_SUCCESS(rv, rv); @@ -1230,12 +1171,8 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation, sourceLocalFile = do_QueryInterface(sourceFile, &rv); NS_ENSURE_SUCCESS(rv, rv); - nsAutoString key; - if (jarEntry.IsEmpty()) { - rv = FileKey(sourceLocalFile, key); - } else { - rv = JarKey(sourceLocalFile, jarEntry, key); - } + nsCAutoString key; + rv = resolvedURI->GetSpec(key); NS_ENSURE_SUCCESS(rv, rv); ModuleEntry* mod; @@ -1391,40 +1328,8 @@ mozJSComponentLoader::Unload(const nsACString & aLocation) rv = scriptChannel->GetURI(getter_AddRefs(resolvedURI)); NS_ENSURE_SUCCESS(rv, rv); - // get the JAR if there is one - nsCOMPtr jarURI; - jarURI = do_QueryInterface(resolvedURI, &rv); - nsCOMPtr baseFileURL; - nsCAutoString jarEntry; - if (NS_SUCCEEDED(rv)) { - nsCOMPtr baseURI; - rv = jarURI->GetJARFile(getter_AddRefs(baseURI)); - NS_ENSURE_SUCCESS(rv, rv); - - baseFileURL = do_QueryInterface(baseURI, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - jarURI->GetJAREntry(jarEntry); - NS_ENSURE_SUCCESS(rv, rv); - } else { - baseFileURL = do_QueryInterface(resolvedURI, &rv); - NS_ENSURE_SUCCESS(rv, rv); - } - - nsCOMPtr sourceFile; - rv = baseFileURL->GetFile(getter_AddRefs(sourceFile)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr sourceLocalFile; - sourceLocalFile = do_QueryInterface(sourceFile, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsAutoString key; - if (jarEntry.IsEmpty()) { - rv = FileKey(sourceLocalFile, key); - } else { - rv = JarKey(sourceLocalFile, jarEntry, key); - } + nsCAutoString key; + rv = resolvedURI->GetSpec(key); NS_ENSURE_SUCCESS(rv, rv); ModuleEntry* mod; diff --git a/js/xpconnect/loader/mozJSComponentLoader.h b/js/xpconnect/loader/mozJSComponentLoader.h index 6e96c44d0104..3304edb8f680 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.h +++ b/js/xpconnect/loader/mozJSComponentLoader.h @@ -89,13 +89,8 @@ class mozJSComponentLoader : public mozilla::ModuleLoader, nsresult ReallyInit(); void UnloadModules(); - nsresult FileKey(nsILocalFile* aFile, nsAString &aResult); - nsresult JarKey(nsILocalFile* aFile, - const nsACString& aComponentPath, - nsAString &aResult); - const mozilla::Module* LoadModuleImpl(nsILocalFile* aSourceFile, - nsAString &aKey, + nsACString &aKey, nsIURI* aComponentURI); nsresult GlobalForLocation(nsILocalFile* aComponentFile, @@ -162,11 +157,11 @@ class mozJSComponentLoader : public mozilla::ModuleLoader, friend class ModuleEntry; // Modules are intentionally leaked, but still cleared. - static PLDHashOperator ClearModules(const nsAString& key, ModuleEntry*& entry, void* cx); - nsDataHashtable mModules; + static PLDHashOperator ClearModules(const nsACString& key, ModuleEntry*& entry, void* cx); + nsDataHashtable mModules; - nsClassHashtable mImports; - nsDataHashtable mInProgressImports; + nsClassHashtable mImports; + nsDataHashtable mInProgressImports; bool mInitialized; };