Backed out 3 changesets (bug 1752209, bug 1752212) for causing build bustages on nsXULPrototypeCache.cpp. CLOSED TREE
authorcriss <ccozmuta@mozilla.com>
Wed, 13 Apr 2022 16:09:50 +0300
changeset 614182 84a0dcf54a260865312c902466be7dbfe92b13ea
parent 614181 4be9243e7f3798ab6517837419ce70e740184f1d
child 614183 d189ac7f06f5cc7c2ff93cc813f5df0162016f36
push id39558
push usernfay@mozilla.com
push dateWed, 13 Apr 2022 18:06:38 +0000
treeherdermozilla-central@4f936f5e57c8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1752209, 1752212
milestone101.0a1
backs out8f10b666008a6ece0b513787ca332c766d11ce34
557c428fb6bcbc17a4ef6923567abc399ec35e4b
e38fbd381ed38b552856dcf5a972ef648405a491
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 3 changesets (bug 1752209, bug 1752212) for causing build bustages on nsXULPrototypeCache.cpp. CLOSED TREE Backed out changeset 8f10b666008a (bug 1752209) Backed out changeset 557c428fb6bc (bug 1752212) Backed out changeset e38fbd381ed3 (bug 1752212)
dom/base/nsFrameMessageManager.cpp
dom/prototype/PrototypeDocumentContentSink.cpp
dom/xul/nsXULElement.cpp
dom/xul/nsXULPrototypeCache.cpp
dom/xul/nsXULPrototypeCache.h
js/xpconnect/loader/mozJSComponentLoader.cpp
js/xpconnect/loader/mozJSSubScriptLoader.cpp
startupcache/StartupCacheUtils.cpp
startupcache/StartupCacheUtils.h
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -64,17 +64,16 @@
 #include "mozilla/dom/RootedDictionary.h"
 #include "mozilla/dom/SameProcessMessageQueue.h"
 #include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/ToJSValue.h"
 #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"
 #include "nsClassHashtable.h"
 #include "nsComponentManagerUtils.h"
 #include "nsContentUtils.h"
 #include "nsCycleCollectionNoteChild.h"
 #include "nsCycleCollectionParticipant.h"
@@ -126,18 +125,16 @@
 #ifdef FUZZING
 #  include "MessageManagerFuzzer.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::dom::ipc;
 
-#define CACHE_PREFIX(type) "mm/" type
-
 nsFrameMessageManager::nsFrameMessageManager(MessageManagerCallback* aCallback,
                                              MessageManagerFlags aFlags)
     : mChrome(aFlags & MessageManagerFlags::MM_CHROME),
       mGlobal(aFlags & MessageManagerFlags::MM_GLOBAL),
       mIsProcessManager(aFlags & MessageManagerFlags::MM_PROCESSMANAGER),
       mIsBroadcaster(aFlags & MessageManagerFlags::MM_BROADCASTER),
       mOwnsCallback(aFlags & MessageManagerFlags::MM_OWNSCALLBACK),
       mHandlingMessage(false),
@@ -1270,24 +1267,20 @@ nsMessageManagerScriptExecutor::TryCache
   AutoJSAPI jsapi;
   if (!jsapi.Init(isRunOnce ? aMessageManager : xpc::CompilationScope())) {
     return nullptr;
   }
   JSContext* cx = jsapi.cx();
 
   RefPtr<JS::Stencil> stencil;
   if (useScriptPreloader) {
-    nsAutoCString cachePath;
-    rv = scache::PathifyURI(CACHE_PREFIX("script"), uri, cachePath);
-    NS_ENSURE_SUCCESS(rv, nullptr);
-
     JS::DecodeOptions decodeOptions;
     ScriptPreloader::FillDecodeOptionsForCachedStencil(decodeOptions);
     stencil = ScriptPreloader::GetChildSingleton().GetCachedStencil(
-        cx, decodeOptions, cachePath);
+        cx, decodeOptions, url);
   }
 
   if (!stencil) {
     nsCOMPtr<nsIChannel> channel;
     NS_NewChannel(getter_AddRefs(channel), uri,
                   nsContentUtils::GetSystemPrincipal(),
                   nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
                   nsIContentPolicy::TYPE_INTERNAL_FRAME_MESSAGEMANAGER_SCRIPT);
@@ -1352,20 +1345,17 @@ nsMessageManagerScriptExecutor::TryCache
     JS::InstantiateOptions instantiateOptions(options);
     instantiateOptions.assertDefault();
 #endif
   }
 
   MOZ_ASSERT(stencil);
 
   if (useScriptPreloader) {
-    nsAutoCString cachePath;
-    rv = scache::PathifyURI(CACHE_PREFIX("script"), uri, cachePath);
-    NS_ENSURE_SUCCESS(rv, nullptr);
-    ScriptPreloader::GetChildSingleton().NoteStencil(url, cachePath, stencil,
+    ScriptPreloader::GetChildSingleton().NoteStencil(url, url, stencil,
                                                      isRunOnce);
   }
 
   return stencil.forget();
 }
 
 void nsMessageManagerScriptExecutor::Trace(const TraceCallbacks& aCallbacks,
                                            void* aClosure) {
--- a/dom/prototype/PrototypeDocumentContentSink.cpp
+++ b/dom/prototype/PrototypeDocumentContentSink.cpp
@@ -666,18 +666,17 @@ nsresult PrototypeDocumentContentSink::D
     mScriptLoader->DeferCheckpointReached();
   }
 
   StartLayout();
 
   if (IsChromeURI(mDocumentURI) &&
       nsXULPrototypeCache::GetInstance()->IsEnabled()) {
     bool isCachedOnDisk;
-    nsXULPrototypeCache::GetInstance()->HasPrototype(mDocumentURI,
-                                                     &isCachedOnDisk);
+    nsXULPrototypeCache::GetInstance()->HasData(mDocumentURI, &isCachedOnDisk);
     if (!isCachedOnDisk) {
       nsXULPrototypeCache::GetInstance()->WritePrototype(mCurrentPrototype);
     }
   }
 
   mDocument->SetDelayFrameLoaderInitialization(false);
   mDocument->MaybeInitializeFinalizeFrameLoaders();
 
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -1665,34 +1665,34 @@ nsresult nsXULPrototypeScript::Serialize
     return NS_ERROR_NOT_IMPLEMENTED;
 
   nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
   if (!cache) return NS_ERROR_OUT_OF_MEMORY;
 
   NS_ASSERTION(cache->IsEnabled(),
                "writing to the cache file, but the XUL cache is off?");
   bool exists;
-  cache->HasScript(mSrcURI, &exists);
+  cache->HasData(mSrcURI, &exists);
 
   /* return will be NS_OK from GetAsciiSpec.
    * that makes no sense.
    * nor does returning NS_OK from HasMuxedDocument.
    * XXX return something meaningful.
    */
   if (exists) return NS_OK;
 
   nsCOMPtr<nsIObjectOutputStream> oos;
-  nsresult rv = cache->GetScriptOutputStream(mSrcURI, getter_AddRefs(oos));
+  nsresult rv = cache->GetOutputStream(mSrcURI, getter_AddRefs(oos));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsresult tmp = Serialize(oos, aProtoDoc, nullptr);
   if (NS_FAILED(tmp)) {
     rv = tmp;
   }
-  tmp = cache->FinishScriptOutputStream(mSrcURI);
+  tmp = cache->FinishOutputStream(mSrcURI);
   if (NS_FAILED(tmp)) {
     rv = tmp;
   }
 
   if (NS_FAILED(rv)) cache->AbortCaching();
   return rv;
 }
 
@@ -1749,17 +1749,17 @@ nsresult nsXULPrototypeScript::Deseriali
         if (newStencil) {
           Set(newStencil);
         }
       }
     }
 
     if (!mStencil) {
       if (mSrcURI) {
-        rv = cache->GetScriptInputStream(mSrcURI, getter_AddRefs(objectInput));
+        rv = cache->GetInputStream(mSrcURI, getter_AddRefs(objectInput));
       }
       // If !mSrcURI, we have an inline script. We shouldn't have
       // to do anything else in that case, I think.
 
       // We do reflect errors into rv, but our caller may want to
       // ignore our return value, because mStencil will be null
       // after any error, and that suffices to cause the script to
       // be reloaded (from the src= URI, if any) and recompiled.
@@ -1767,17 +1767,17 @@ nsresult nsXULPrototypeScript::Deseriali
       // error.
       if (NS_SUCCEEDED(rv))
         rv = Deserialize(objectInput, aProtoDoc, nullptr, nullptr);
 
       if (NS_SUCCEEDED(rv)) {
         if (useXULCache && mSrcURI && mSrcURI->SchemeIs("chrome")) {
           cache->PutStencil(mSrcURI, GetStencil());
         }
-        cache->FinishScriptInputStream(mSrcURI);
+        cache->FinishInputStream(mSrcURI);
       } else {
         // If mSrcURI is not in the cache,
         // rv will be NS_ERROR_NOT_AVAILABLE and we'll try to
         // update the cache file to hold a serialization of
         // this script, once it has finished loading.
         if (rv != NS_ERROR_NOT_AVAILABLE) cache->AbortCaching();
       }
     }
--- a/dom/xul/nsXULPrototypeCache.cpp
+++ b/dom/xul/nsXULPrototypeCache.cpp
@@ -32,17 +32,17 @@
 #include "mozilla/RefPtr.h"
 #include "mozilla/intl/LocaleService.h"
 
 using namespace mozilla;
 using namespace mozilla::scache;
 using mozilla::intl::LocaleService;
 
 static const char kXULCacheInfoKey[] = "nsXULPrototypeCache.startupCache";
-#define CACHE_PREFIX(aCompilationTarget) "xulcache/" aCompilationTarget
+static const char kXULCachePrefix[] = "xulcache";
 
 static void DisableXULCacheChangedCallback(const char* aPref, void* aClosure) {
   if (nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance()) {
     if (!cache->IsEnabled()) {
       // AbortCaching() calls Flush() for us.
       cache->AbortCaching();
     }
   }
@@ -105,17 +105,17 @@ nsXULPrototypeDocument* nsXULPrototypeCa
     return protoDoc;
   }
 
   nsresult rv = BeginCaching(aURI);
   if (NS_FAILED(rv)) return nullptr;
 
   // No prototype in XUL memory cache. Spin up the cache Service.
   nsCOMPtr<nsIObjectInputStream> ois;
-  rv = GetPrototypeInputStream(aURI, getter_AddRefs(ois));
+  rv = GetInputStream(aURI, getter_AddRefs(ois));
   if (NS_FAILED(rv)) {
     return nullptr;
   }
 
   RefPtr<nsXULPrototypeDocument> newProto;
   rv = NS_NewXULPrototypeDocument(getter_AddRefs(newProto));
   if (NS_FAILED(rv)) return nullptr;
 
@@ -192,39 +192,29 @@ nsresult nsXULPrototypeCache::WriteProto
     nsXULPrototypeDocument* aPrototypeDocument) {
   nsresult rv = NS_OK, rv2 = NS_OK;
 
   if (!StartupCache::GetSingleton()) return NS_OK;
 
   nsCOMPtr<nsIURI> protoURI = aPrototypeDocument->GetURI();
 
   nsCOMPtr<nsIObjectOutputStream> oos;
-  rv = GetPrototypeOutputStream(protoURI, getter_AddRefs(oos));
+  rv = GetOutputStream(protoURI, getter_AddRefs(oos));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = aPrototypeDocument->Write(oos);
   NS_ENSURE_SUCCESS(rv, rv);
-  FinishPrototypeOutputStream(protoURI);
+  FinishOutputStream(protoURI);
   return NS_FAILED(rv) ? rv : rv2;
 }
 
-static nsresult PathifyURIForType(nsXULPrototypeCache::CacheType cacheType,
-                                  nsIURI* in, nsACString& out) {
-  switch (cacheType) {
-    case nsXULPrototypeCache::CacheType::Prototype:
-      return PathifyURI(CACHE_PREFIX("proto"), in, out);
-    case nsXULPrototypeCache::CacheType::Script:
-      return PathifyURI(CACHE_PREFIX("script"), in, out);
-  }
-}
-
-nsresult nsXULPrototypeCache::GetInputStream(CacheType cacheType, nsIURI* uri,
+nsresult nsXULPrototypeCache::GetInputStream(nsIURI* uri,
                                              nsIObjectInputStream** stream) {
-  nsAutoCString spec;
-  nsresult rv = PathifyURIForType(cacheType, uri, spec);
+  nsAutoCString spec(kXULCachePrefix);
+  nsresult rv = PathifyURI(uri, spec);
   if (NS_FAILED(rv)) return NS_ERROR_NOT_AVAILABLE;
 
   const char* buf;
   uint32_t len;
   nsCOMPtr<nsIObjectInputStream> ois;
   StartupCache* sc = StartupCache::GetSingleton();
   if (!sc) return NS_ERROR_NOT_AVAILABLE;
 
@@ -266,57 +256,55 @@ nsresult nsXULPrototypeCache::GetOutputS
         getter_AddRefs(objectOutput), getter_AddRefs(storageStream), false);
     NS_ENSURE_SUCCESS(rv, rv);
     mOutputStreamTable.InsertOrUpdate(uri, storageStream);
   }
   objectOutput.forget(stream);
   return NS_OK;
 }
 
-nsresult nsXULPrototypeCache::FinishOutputStream(CacheType cacheType,
-                                                 nsIURI* uri) {
+nsresult nsXULPrototypeCache::FinishOutputStream(nsIURI* uri) {
   nsresult rv;
   StartupCache* sc = StartupCache::GetSingleton();
   if (!sc) return NS_ERROR_NOT_AVAILABLE;
 
   nsCOMPtr<nsIStorageStream> storageStream;
   bool found = mOutputStreamTable.Get(uri, getter_AddRefs(storageStream));
   if (!found) return NS_ERROR_UNEXPECTED;
   nsCOMPtr<nsIOutputStream> outputStream = do_QueryInterface(storageStream);
   outputStream->Close();
 
   UniquePtr<char[]> buf;
   uint32_t len;
   rv = NewBufferFromStorageStream(storageStream, &buf, &len);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!mStartupCacheURITable.GetEntry(uri)) {
-    nsAutoCString spec;
-    rv = PathifyURIForType(cacheType, uri, spec);
+    nsAutoCString spec(kXULCachePrefix);
+    rv = PathifyURI(uri, spec);
     if (NS_FAILED(rv)) return NS_ERROR_NOT_AVAILABLE;
     rv = sc->PutBuffer(spec.get(), std::move(buf), len);
     if (NS_SUCCEEDED(rv)) {
       mOutputStreamTable.Remove(uri);
       mStartupCacheURITable.PutEntry(uri);
     }
   }
 
   return rv;
 }
 
 // We have data if we're in the middle of writing it or we already
 // have it in the cache.
-nsresult nsXULPrototypeCache::HasData(CacheType cacheType, nsIURI* uri,
-                                      bool* exists) {
+nsresult nsXULPrototypeCache::HasData(nsIURI* uri, bool* exists) {
   if (mOutputStreamTable.Get(uri, nullptr)) {
     *exists = true;
     return NS_OK;
   }
-  nsAutoCString spec;
-  nsresult rv = PathifyURIForType(cacheType, uri, spec);
+  nsAutoCString spec(kXULCachePrefix);
+  nsresult rv = PathifyURI(uri, spec);
   if (NS_FAILED(rv)) {
     *exists = false;
     return NS_OK;
   }
   UniquePtr<char[]> buf;
   StartupCache* sc = StartupCache::GetSingleton();
   if (sc) {
     *exists = sc->HasEntry(spec.get());
--- a/dom/xul/nsXULPrototypeCache.h
+++ b/dom/xul/nsXULPrototypeCache.h
@@ -29,18 +29,16 @@ class StyleSheet;
  * XUL documents, style sheets, XBL, and scripts.
  *
  * The cache has two levels:
  *  1. In-memory hashtables
  *  2. The on-disk cache file.
  */
 class nsXULPrototypeCache : public nsIObserver {
  public:
-  enum class CacheType { Prototype, Script };
-
   // nsISupports
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
   bool IsCached(nsIURI* aURI) { return GetPrototype(aURI) != nullptr; }
   void AbortCaching();
 
   /**
@@ -68,62 +66,22 @@ class nsXULPrototypeCache : public nsIOb
    * fully loaded.
    */
   nsresult WritePrototype(nsXULPrototypeDocument* aPrototypeDocument);
 
   /**
    * This interface allows partial reads and writes from the buffers in the
    * startupCache.
    */
-
-  inline nsresult GetPrototypeInputStream(nsIURI* aURI,
-                                          nsIObjectInputStream** objectInput) {
-    return GetInputStream(CacheType::Prototype, aURI, objectInput);
-  }
-  inline nsresult GetScriptInputStream(nsIURI* aURI,
-                                       nsIObjectInputStream** objectInput) {
-    return GetInputStream(CacheType::Script, aURI, objectInput);
-  }
-  inline nsresult FinishScriptInputStream(nsIURI* aURI) {
-    return FinishInputStream(aURI);
-  }
-
-  inline nsresult GetPrototypeOutputStream(
-      nsIURI* aURI, nsIObjectOutputStream** objectOutput) {
-    return GetOutputStream(aURI, objectOutput);
-  }
-  inline nsresult GetScriptOutputStream(nsIURI* aURI,
-                                        nsIObjectOutputStream** objectOutput) {
-    return GetOutputStream(aURI, objectOutput);
-  }
+  nsresult GetInputStream(nsIURI* aURI, nsIObjectInputStream** objectInput);
+  nsresult FinishInputStream(nsIURI* aURI);
+  nsresult GetOutputStream(nsIURI* aURI, nsIObjectOutputStream** objectOutput);
+  nsresult FinishOutputStream(nsIURI* aURI);
+  nsresult HasData(nsIURI* aURI, bool* exists);
 
-  inline nsresult FinishPrototypeOutputStream(nsIURI* aURI) {
-    return FinishOutputStream(CacheType::Prototype, aURI);
-  }
-  inline nsresult FinishScriptOutputStream(nsIURI* aURI) {
-    return FinishOutputStream(CacheType::Script, aURI);
-  }
-
-  inline nsresult HasPrototype(nsIURI* aURI, bool* exists) {
-    return HasData(CacheType::Prototype, aURI, exists);
-  }
-  inline nsresult HasScript(nsIURI* aURI, bool* exists) {
-    return HasData(CacheType::Script, aURI, exists);
-  }
-
- private:
-  nsresult GetInputStream(CacheType cacheType, nsIURI* uri,
-                          nsIObjectInputStream** stream);
-  nsresult FinishInputStream(nsIURI* aURI);
-
-  nsresult GetOutputStream(nsIURI* aURI, nsIObjectOutputStream** objectOutput);
-  nsresult FinishOutputStream(CacheType cacheType, nsIURI* aURI);
-  nsresult HasData(CacheType cacheType, nsIURI* aURI, bool* exists);
-
- public:
   static nsXULPrototypeCache* GetInstance();
   static nsXULPrototypeCache* MaybeGetInstance() { return sInstance; }
 
   static void ReleaseGlobals() { NS_IF_RELEASE(sInstance); }
 
   void MarkInCCGeneration(uint32_t aGeneration);
 
   static void CollectMemoryReports(nsIHandleReportCallback* aHandleReport,
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -70,18 +70,17 @@
 #include "mozilla/Unused.h"
 
 using namespace mozilla;
 using namespace mozilla::scache;
 using namespace mozilla::loader;
 using namespace xpc;
 using namespace JS;
 
-#define JS_CACHE_PREFIX(aScopeType, aCompilationTarget) \
-  "jsloader/" aScopeType "/" aCompilationTarget
+#define JS_CACHE_PREFIX(aType) "jsloader/" aType
 
 /**
  * Buffer sizes for serialization and deserialization of scripts.
  * FIXME: bug #411579 (tune this macro!) Last updated: Jan 2008
  */
 #define XPC_SERIALIZATION_BUFFER_SIZE (64 * 1024)
 #define XPC_DESERIALIZATION_BUFFER_SIZE (12 * 8192)
 
@@ -743,19 +742,18 @@ nsresult mozJSComponentLoader::ObjectFor
   // errors and startupcache errors are not fatal to loading the script, since
   // we can always slow-load.
 
   bool storeIntoStartupCache = false;
   StartupCache* cache = StartupCache::GetSingleton();
 
   aInfo.EnsureResolvedURI();
 
-  nsAutoCString cachePath;
-  rv = PathifyURI(JS_CACHE_PREFIX("non-syntactic", "script"),
-                  aInfo.ResolvedURI(), cachePath);
+  nsAutoCString cachePath(JS_CACHE_PREFIX("non-syntactic"));
+  rv = PathifyURI(aInfo.ResolvedURI(), cachePath);
   NS_ENSURE_SUCCESS(rv, rv);
 
   JS::DecodeOptions decodeOptions;
   ScriptPreloader::FillDecodeOptionsForCachedStencil(decodeOptions);
 
   RefPtr<JS::Stencil> stencil =
       ScriptPreloader::GetSingleton().GetCachedStencil(cx, decodeOptions,
                                                        cachePath);
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -76,29 +76,29 @@ class MOZ_STACK_CLASS LoadSubScriptOptio
 #define LOAD_ERROR_CONTENTTOOBIG "ContentLength is too large"
 
 mozJSSubScriptLoader::mozJSSubScriptLoader() = default;
 
 mozJSSubScriptLoader::~mozJSSubScriptLoader() = default;
 
 NS_IMPL_ISUPPORTS(mozJSSubScriptLoader, mozIJSSubScriptLoader)
 
-#define JSSUB_CACHE_PREFIX(aScopeType, aCompilationTarget) \
-  "jssubloader/" aScopeType "/" aCompilationTarget
+#define JSSUB_CACHE_PREFIX(aType) "jssubloader/" aType
 
 static void SubscriptCachePath(JSContext* cx, nsIURI* uri,
                                JS::HandleObject targetObj,
                                nsACString& cachePath) {
   // StartupCache must distinguish between non-syntactic vs global when
   // computing the cache key.
   if (!JS_IsGlobalObject(targetObj)) {
-    PathifyURI(JSSUB_CACHE_PREFIX("non-syntactic", "script"), uri, cachePath);
+    cachePath.AssignLiteral(JSSUB_CACHE_PREFIX("non-syntactic"));
   } else {
-    PathifyURI(JSSUB_CACHE_PREFIX("global", "script"), uri, cachePath);
+    cachePath.AssignLiteral(JSSUB_CACHE_PREFIX("global"));
   }
+  PathifyURI(uri, cachePath);
 }
 
 static void ReportError(JSContext* cx, const nsACString& msg) {
   NS_ConvertUTF8toUTF16 ucMsg(msg);
 
   RootedValue exn(cx);
   if (xpc::NonVoidStringToJsval(cx, ucMsg, &exn)) {
     JS_SetPendingException(cx, exn);
--- a/startupcache/StartupCacheUtils.cpp
+++ b/startupcache/StartupCacheUtils.cpp
@@ -161,17 +161,42 @@ nsresult ResolveURI(nsIURI* in, nsIURI**
 
     return chromeReg->ConvertChromeURL(in, out);
   }
 
   *out = do_AddRef(in).take();
   return NS_OK;
 }
 
-static nsresult PathifyURIImpl(nsIURI* in, nsACString& out) {
+/**
+ * PathifyURI transforms uris into useful zip paths
+ * to make it easier to manipulate startup cache entries
+ * using standard zip tools.
+ * Transformations applied:
+ *  * resource:// URIs are resolved to their corresponding file/jar URI to
+ *    canonicalize resources URIs other than gre and app.
+ *  * Paths under GRE or APP directory have their base path replaced with
+ *    resource/gre or resource/app to avoid depending on install location.
+ *  * jar:file:///path/to/file.jar!/sub/path urls are replaced with
+ *    /path/to/file.jar/sub/path
+ *
+ *  The result is appended to the string passed in. Adding a prefix before
+ *  calling is recommended to avoid colliding with other cache users.
+ *
+ * For example, in the js loader (string is prefixed with jsloader by caller):
+ *  resource://gre/modules/XPCOMUtils.jsm or
+ *  file://$GRE_DIR/modules/XPCOMUtils.jsm or
+ *  jar:file://$GRE_DIR/omni.jar!/modules/XPCOMUtils.jsm becomes
+ *     jsloader/resource/gre/modules/XPCOMUtils.jsm
+ *  file://$PROFILE_DIR/extensions/{uuid}/components/component.js becomes
+ *     jsloader/$PROFILE_DIR/extensions/%7Buuid%7D/components/component.js
+ *  jar:file://$PROFILE_DIR/extensions/some.xpi!/components/component.js becomes
+ *     jsloader/$PROFILE_DIR/extensions/some.xpi/components/component.js
+ */
+nsresult PathifyURI(nsIURI* in, nsACString& out) {
   nsCOMPtr<nsIURI> uri;
   nsresult rv = ResolveURI(in, getter_AddRefs(uri));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString spec;
   rv = uri->GetSpec(spec);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -189,17 +214,17 @@ static nsresult PathifyURIImpl(nsIURI* i
     } else if (uri->SchemeIs("jar")) {
       nsCOMPtr<nsIJARURI> jarURI = do_QueryInterface(uri, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsCOMPtr<nsIURI> jarFileURI;
       rv = jarURI->GetJARFile(getter_AddRefs(jarFileURI));
       NS_ENSURE_SUCCESS(rv, rv);
 
-      rv = PathifyURIImpl(jarFileURI, out);
+      rv = PathifyURI(jarFileURI, out);
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsAutoCString path;
       rv = jarURI->GetJAREntry(path);
       NS_ENSURE_SUCCESS(rv, rv);
       out.Append('/');
       out.Append(path);
     } else {  // Very unlikely
@@ -208,17 +233,10 @@ static nsresult PathifyURIImpl(nsIURI* i
 
       out.Append('/');
       out.Append(spec);
     }
   }
   return NS_OK;
 }
 
-nsresult PathifyURI(const char* loaderType, size_t loaderTypeLength, nsIURI* in,
-                    nsACString& out) {
-  out.AssignASCII(loaderType, loaderTypeLength);
-
-  return PathifyURIImpl(in, out);
-}
-
 }  // namespace scache
 }  // namespace mozilla
--- a/startupcache/StartupCacheUtils.h
+++ b/startupcache/StartupCacheUtils.h
@@ -32,44 +32,13 @@ nsresult NewObjectOutputWrappedStorageSt
 // Creates a buffer for storing the stream into the cache. The buffer is
 // allocated with 'new []'.  After calling this function, the caller would
 // typically call StartupCache::PutBuffer with the returned buffer.
 nsresult NewBufferFromStorageStream(nsIStorageStream* storageStream,
                                     UniquePtr<char[]>* buffer, uint32_t* len);
 
 nsresult ResolveURI(nsIURI* in, nsIURI** out);
 
-// PathifyURI transforms uris into useful zip paths
-// to make it easier to manipulate startup cache entries
-// using standard zip tools.
-//
-// Transformations applied:
-//  * resource:// URIs are resolved to their corresponding file/jar URI to
-//    canonicalize resources URIs other than gre and app.
-//  * Paths under GRE or APP directory have their base path replaced with
-//    resource/gre or resource/app to avoid depending on install location.
-//  * jar:file:///path/to/file.jar!/sub/path urls are replaced with
-//    /path/to/file.jar/sub/path
-//
-// The result is concatenated with loaderType and stored into the string
-// passed in.
-//
-// For example, in the js loader (loaderType = "jsloader"):
-//  resource://gre/modules/XPCOMUtils.jsm or
-//  file://$GRE_DIR/modules/XPCOMUtils.jsm or
-//  jar:file://$GRE_DIR/omni.jar!/modules/XPCOMUtils.jsm becomes
-//     jsloader/resource/gre/modules/XPCOMUtils.jsm
-//  file://$PROFILE_DIR/extensions/{uuid}/components/component.js becomes
-//     jsloader/$PROFILE_DIR/extensions/%7Buuid%7D/components/component.js
-//  jar:file://$PROFILE_DIR/extensions/some.xpi!/components/component.js becomes
-//     jsloader/$PROFILE_DIR/extensions/some.xpi/components/component.js
-nsresult PathifyURI(const char* loaderType, size_t loaderTypeLength, nsIURI* in,
-                    nsACString& out);
-
-template <int N>
-nsresult PathifyURI(const char (&loaderType)[N], nsIURI* in, nsACString& out) {
-  return PathifyURI(loaderType, N - 1, in, out);
-}
-
+nsresult PathifyURI(nsIURI* in, nsACString& out);
 }  // namespace scache
 }  // namespace mozilla
 
 #endif  // nsStartupCacheUtils_h_