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)
This commit is contained in:
@@ -69,7 +69,6 @@
|
|||||||
#include "mozilla/dom/MessageManagerCallback.h"
|
#include "mozilla/dom/MessageManagerCallback.h"
|
||||||
#include "mozilla/dom/ipc/SharedMap.h"
|
#include "mozilla/dom/ipc/SharedMap.h"
|
||||||
#include "mozilla/dom/ipc/StructuredCloneData.h"
|
#include "mozilla/dom/ipc/StructuredCloneData.h"
|
||||||
#include "mozilla/scache/StartupCacheUtils.h"
|
|
||||||
#include "nsASCIIMask.h"
|
#include "nsASCIIMask.h"
|
||||||
#include "nsBaseHashtable.h"
|
#include "nsBaseHashtable.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
@@ -131,8 +130,6 @@ using namespace mozilla;
|
|||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
using namespace mozilla::dom::ipc;
|
using namespace mozilla::dom::ipc;
|
||||||
|
|
||||||
#define CACHE_PREFIX(type) "mm/" type
|
|
||||||
|
|
||||||
nsFrameMessageManager::nsFrameMessageManager(MessageManagerCallback* aCallback,
|
nsFrameMessageManager::nsFrameMessageManager(MessageManagerCallback* aCallback,
|
||||||
MessageManagerFlags aFlags)
|
MessageManagerFlags aFlags)
|
||||||
: mChrome(aFlags & MessageManagerFlags::MM_CHROME),
|
: mChrome(aFlags & MessageManagerFlags::MM_CHROME),
|
||||||
@@ -1275,14 +1272,10 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
|
|||||||
|
|
||||||
RefPtr<JS::Stencil> stencil;
|
RefPtr<JS::Stencil> stencil;
|
||||||
if (useScriptPreloader) {
|
if (useScriptPreloader) {
|
||||||
nsAutoCString cachePath;
|
|
||||||
rv = scache::PathifyURI(CACHE_PREFIX("script"), uri, cachePath);
|
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
|
||||||
|
|
||||||
JS::DecodeOptions decodeOptions;
|
JS::DecodeOptions decodeOptions;
|
||||||
ScriptPreloader::FillDecodeOptionsForCachedStencil(decodeOptions);
|
ScriptPreloader::FillDecodeOptionsForCachedStencil(decodeOptions);
|
||||||
stencil = ScriptPreloader::GetChildSingleton().GetCachedStencil(
|
stencil = ScriptPreloader::GetChildSingleton().GetCachedStencil(
|
||||||
cx, decodeOptions, cachePath);
|
cx, decodeOptions, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stencil) {
|
if (!stencil) {
|
||||||
@@ -1357,10 +1350,7 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
|
|||||||
MOZ_ASSERT(stencil);
|
MOZ_ASSERT(stencil);
|
||||||
|
|
||||||
if (useScriptPreloader) {
|
if (useScriptPreloader) {
|
||||||
nsAutoCString cachePath;
|
ScriptPreloader::GetChildSingleton().NoteStencil(url, url, stencil,
|
||||||
rv = scache::PathifyURI(CACHE_PREFIX("script"), uri, cachePath);
|
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
|
||||||
ScriptPreloader::GetChildSingleton().NoteStencil(url, cachePath, stencil,
|
|
||||||
isRunOnce);
|
isRunOnce);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -671,8 +671,7 @@ nsresult PrototypeDocumentContentSink::DoneWalking() {
|
|||||||
if (IsChromeURI(mDocumentURI) &&
|
if (IsChromeURI(mDocumentURI) &&
|
||||||
nsXULPrototypeCache::GetInstance()->IsEnabled()) {
|
nsXULPrototypeCache::GetInstance()->IsEnabled()) {
|
||||||
bool isCachedOnDisk;
|
bool isCachedOnDisk;
|
||||||
nsXULPrototypeCache::GetInstance()->HasPrototype(mDocumentURI,
|
nsXULPrototypeCache::GetInstance()->HasData(mDocumentURI, &isCachedOnDisk);
|
||||||
&isCachedOnDisk);
|
|
||||||
if (!isCachedOnDisk) {
|
if (!isCachedOnDisk) {
|
||||||
nsXULPrototypeCache::GetInstance()->WritePrototype(mCurrentPrototype);
|
nsXULPrototypeCache::GetInstance()->WritePrototype(mCurrentPrototype);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1670,7 +1670,7 @@ nsresult nsXULPrototypeScript::SerializeOutOfLine(
|
|||||||
NS_ASSERTION(cache->IsEnabled(),
|
NS_ASSERTION(cache->IsEnabled(),
|
||||||
"writing to the cache file, but the XUL cache is off?");
|
"writing to the cache file, but the XUL cache is off?");
|
||||||
bool exists;
|
bool exists;
|
||||||
cache->HasScript(mSrcURI, &exists);
|
cache->HasData(mSrcURI, &exists);
|
||||||
|
|
||||||
/* return will be NS_OK from GetAsciiSpec.
|
/* return will be NS_OK from GetAsciiSpec.
|
||||||
* that makes no sense.
|
* that makes no sense.
|
||||||
@@ -1680,14 +1680,14 @@ nsresult nsXULPrototypeScript::SerializeOutOfLine(
|
|||||||
if (exists) return NS_OK;
|
if (exists) return NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsIObjectOutputStream> oos;
|
nsCOMPtr<nsIObjectOutputStream> oos;
|
||||||
nsresult rv = cache->GetScriptOutputStream(mSrcURI, getter_AddRefs(oos));
|
nsresult rv = cache->GetOutputStream(mSrcURI, getter_AddRefs(oos));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsresult tmp = Serialize(oos, aProtoDoc, nullptr);
|
nsresult tmp = Serialize(oos, aProtoDoc, nullptr);
|
||||||
if (NS_FAILED(tmp)) {
|
if (NS_FAILED(tmp)) {
|
||||||
rv = tmp;
|
rv = tmp;
|
||||||
}
|
}
|
||||||
tmp = cache->FinishScriptOutputStream(mSrcURI);
|
tmp = cache->FinishOutputStream(mSrcURI);
|
||||||
if (NS_FAILED(tmp)) {
|
if (NS_FAILED(tmp)) {
|
||||||
rv = tmp;
|
rv = tmp;
|
||||||
}
|
}
|
||||||
@@ -1754,7 +1754,7 @@ nsresult nsXULPrototypeScript::DeserializeOutOfLine(
|
|||||||
|
|
||||||
if (!mStencil) {
|
if (!mStencil) {
|
||||||
if (mSrcURI) {
|
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
|
// If !mSrcURI, we have an inline script. We shouldn't have
|
||||||
// to do anything else in that case, I think.
|
// to do anything else in that case, I think.
|
||||||
@@ -1772,7 +1772,7 @@ nsresult nsXULPrototypeScript::DeserializeOutOfLine(
|
|||||||
if (useXULCache && mSrcURI && mSrcURI->SchemeIs("chrome")) {
|
if (useXULCache && mSrcURI && mSrcURI->SchemeIs("chrome")) {
|
||||||
cache->PutStencil(mSrcURI, GetStencil());
|
cache->PutStencil(mSrcURI, GetStencil());
|
||||||
}
|
}
|
||||||
cache->FinishScriptInputStream(mSrcURI);
|
cache->FinishInputStream(mSrcURI);
|
||||||
} else {
|
} else {
|
||||||
// If mSrcURI is not in the cache,
|
// If mSrcURI is not in the cache,
|
||||||
// rv will be NS_ERROR_NOT_AVAILABLE and we'll try to
|
// rv will be NS_ERROR_NOT_AVAILABLE and we'll try to
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ using namespace mozilla::scache;
|
|||||||
using mozilla::intl::LocaleService;
|
using mozilla::intl::LocaleService;
|
||||||
|
|
||||||
static const char kXULCacheInfoKey[] = "nsXULPrototypeCache.startupCache";
|
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) {
|
static void DisableXULCacheChangedCallback(const char* aPref, void* aClosure) {
|
||||||
if (nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance()) {
|
if (nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance()) {
|
||||||
@@ -110,7 +110,7 @@ nsXULPrototypeDocument* nsXULPrototypeCache::GetPrototype(nsIURI* aURI) {
|
|||||||
|
|
||||||
// No prototype in XUL memory cache. Spin up the cache Service.
|
// No prototype in XUL memory cache. Spin up the cache Service.
|
||||||
nsCOMPtr<nsIObjectInputStream> ois;
|
nsCOMPtr<nsIObjectInputStream> ois;
|
||||||
rv = GetPrototypeInputStream(aURI, getter_AddRefs(ois));
|
rv = GetInputStream(aURI, getter_AddRefs(ois));
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -197,29 +197,19 @@ nsresult nsXULPrototypeCache::WritePrototype(
|
|||||||
nsCOMPtr<nsIURI> protoURI = aPrototypeDocument->GetURI();
|
nsCOMPtr<nsIURI> protoURI = aPrototypeDocument->GetURI();
|
||||||
|
|
||||||
nsCOMPtr<nsIObjectOutputStream> oos;
|
nsCOMPtr<nsIObjectOutputStream> oos;
|
||||||
rv = GetPrototypeOutputStream(protoURI, getter_AddRefs(oos));
|
rv = GetOutputStream(protoURI, getter_AddRefs(oos));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = aPrototypeDocument->Write(oos);
|
rv = aPrototypeDocument->Write(oos);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
FinishPrototypeOutputStream(protoURI);
|
FinishOutputStream(protoURI);
|
||||||
return NS_FAILED(rv) ? rv : rv2;
|
return NS_FAILED(rv) ? rv : rv2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsresult PathifyURIForType(nsXULPrototypeCache::CacheType cacheType,
|
nsresult nsXULPrototypeCache::GetInputStream(nsIURI* uri,
|
||||||
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,
|
|
||||||
nsIObjectInputStream** stream) {
|
nsIObjectInputStream** stream) {
|
||||||
nsAutoCString spec;
|
nsAutoCString spec(kXULCachePrefix);
|
||||||
nsresult rv = PathifyURIForType(cacheType, uri, spec);
|
nsresult rv = PathifyURI(uri, spec);
|
||||||
if (NS_FAILED(rv)) return NS_ERROR_NOT_AVAILABLE;
|
if (NS_FAILED(rv)) return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
||||||
const char* buf;
|
const char* buf;
|
||||||
@@ -271,8 +261,7 @@ nsresult nsXULPrototypeCache::GetOutputStream(nsIURI* uri,
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsXULPrototypeCache::FinishOutputStream(CacheType cacheType,
|
nsresult nsXULPrototypeCache::FinishOutputStream(nsIURI* uri) {
|
||||||
nsIURI* uri) {
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
StartupCache* sc = StartupCache::GetSingleton();
|
StartupCache* sc = StartupCache::GetSingleton();
|
||||||
if (!sc) return NS_ERROR_NOT_AVAILABLE;
|
if (!sc) return NS_ERROR_NOT_AVAILABLE;
|
||||||
@@ -289,8 +278,8 @@ nsresult nsXULPrototypeCache::FinishOutputStream(CacheType cacheType,
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (!mStartupCacheURITable.GetEntry(uri)) {
|
if (!mStartupCacheURITable.GetEntry(uri)) {
|
||||||
nsAutoCString spec;
|
nsAutoCString spec(kXULCachePrefix);
|
||||||
rv = PathifyURIForType(cacheType, uri, spec);
|
rv = PathifyURI(uri, spec);
|
||||||
if (NS_FAILED(rv)) return NS_ERROR_NOT_AVAILABLE;
|
if (NS_FAILED(rv)) return NS_ERROR_NOT_AVAILABLE;
|
||||||
rv = sc->PutBuffer(spec.get(), std::move(buf), len);
|
rv = sc->PutBuffer(spec.get(), std::move(buf), len);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
@@ -304,14 +293,13 @@ nsresult nsXULPrototypeCache::FinishOutputStream(CacheType cacheType,
|
|||||||
|
|
||||||
// We have data if we're in the middle of writing it or we already
|
// We have data if we're in the middle of writing it or we already
|
||||||
// have it in the cache.
|
// have it in the cache.
|
||||||
nsresult nsXULPrototypeCache::HasData(CacheType cacheType, nsIURI* uri,
|
nsresult nsXULPrototypeCache::HasData(nsIURI* uri, bool* exists) {
|
||||||
bool* exists) {
|
|
||||||
if (mOutputStreamTable.Get(uri, nullptr)) {
|
if (mOutputStreamTable.Get(uri, nullptr)) {
|
||||||
*exists = true;
|
*exists = true;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
nsAutoCString spec;
|
nsAutoCString spec(kXULCachePrefix);
|
||||||
nsresult rv = PathifyURIForType(cacheType, uri, spec);
|
nsresult rv = PathifyURI(uri, spec);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
*exists = false;
|
*exists = false;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ class StyleSheet;
|
|||||||
*/
|
*/
|
||||||
class nsXULPrototypeCache : public nsIObserver {
|
class nsXULPrototypeCache : public nsIObserver {
|
||||||
public:
|
public:
|
||||||
enum class CacheType { Prototype, Script };
|
|
||||||
|
|
||||||
// nsISupports
|
// nsISupports
|
||||||
NS_DECL_THREADSAFE_ISUPPORTS
|
NS_DECL_THREADSAFE_ISUPPORTS
|
||||||
NS_DECL_NSIOBSERVER
|
NS_DECL_NSIOBSERVER
|
||||||
@@ -73,52 +71,12 @@ class nsXULPrototypeCache : public nsIObserver {
|
|||||||
* This interface allows partial reads and writes from the buffers in the
|
* This interface allows partial reads and writes from the buffers in the
|
||||||
* startupCache.
|
* startupCache.
|
||||||
*/
|
*/
|
||||||
|
nsresult GetInputStream(nsIURI* aURI, nsIObjectInputStream** objectInput);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 FinishInputStream(nsIURI* aURI);
|
||||||
|
|
||||||
nsresult GetOutputStream(nsIURI* aURI, nsIObjectOutputStream** objectOutput);
|
nsresult GetOutputStream(nsIURI* aURI, nsIObjectOutputStream** objectOutput);
|
||||||
nsresult FinishOutputStream(CacheType cacheType, nsIURI* aURI);
|
nsresult FinishOutputStream(nsIURI* aURI);
|
||||||
nsresult HasData(CacheType cacheType, nsIURI* aURI, bool* exists);
|
nsresult HasData(nsIURI* aURI, bool* exists);
|
||||||
|
|
||||||
public:
|
|
||||||
static nsXULPrototypeCache* GetInstance();
|
static nsXULPrototypeCache* GetInstance();
|
||||||
static nsXULPrototypeCache* MaybeGetInstance() { return sInstance; }
|
static nsXULPrototypeCache* MaybeGetInstance() { return sInstance; }
|
||||||
|
|
||||||
|
|||||||
@@ -75,8 +75,7 @@ using namespace mozilla::loader;
|
|||||||
using namespace xpc;
|
using namespace xpc;
|
||||||
using namespace JS;
|
using namespace JS;
|
||||||
|
|
||||||
#define JS_CACHE_PREFIX(aScopeType, aCompilationTarget) \
|
#define JS_CACHE_PREFIX(aType) "jsloader/" aType
|
||||||
"jsloader/" aScopeType "/" aCompilationTarget
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Buffer sizes for serialization and deserialization of scripts.
|
* Buffer sizes for serialization and deserialization of scripts.
|
||||||
@@ -748,9 +747,8 @@ nsresult mozJSComponentLoader::ObjectForLocation(
|
|||||||
|
|
||||||
aInfo.EnsureResolvedURI();
|
aInfo.EnsureResolvedURI();
|
||||||
|
|
||||||
nsAutoCString cachePath;
|
nsAutoCString cachePath(JS_CACHE_PREFIX("non-syntactic"));
|
||||||
rv = PathifyURI(JS_CACHE_PREFIX("non-syntactic", "script"),
|
rv = PathifyURI(aInfo.ResolvedURI(), cachePath);
|
||||||
aInfo.ResolvedURI(), cachePath);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
JS::DecodeOptions decodeOptions;
|
JS::DecodeOptions decodeOptions;
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ mozJSSubScriptLoader::~mozJSSubScriptLoader() = default;
|
|||||||
|
|
||||||
NS_IMPL_ISUPPORTS(mozJSSubScriptLoader, mozIJSSubScriptLoader)
|
NS_IMPL_ISUPPORTS(mozJSSubScriptLoader, mozIJSSubScriptLoader)
|
||||||
|
|
||||||
#define JSSUB_CACHE_PREFIX(aScopeType, aCompilationTarget) \
|
#define JSSUB_CACHE_PREFIX(aType) "jssubloader/" aType
|
||||||
"jssubloader/" aScopeType "/" aCompilationTarget
|
|
||||||
|
|
||||||
static void SubscriptCachePath(JSContext* cx, nsIURI* uri,
|
static void SubscriptCachePath(JSContext* cx, nsIURI* uri,
|
||||||
JS::HandleObject targetObj,
|
JS::HandleObject targetObj,
|
||||||
@@ -90,10 +89,11 @@ static void SubscriptCachePath(JSContext* cx, nsIURI* uri,
|
|||||||
// StartupCache must distinguish between non-syntactic vs global when
|
// StartupCache must distinguish between non-syntactic vs global when
|
||||||
// computing the cache key.
|
// computing the cache key.
|
||||||
if (!JS_IsGlobalObject(targetObj)) {
|
if (!JS_IsGlobalObject(targetObj)) {
|
||||||
PathifyURI(JSSUB_CACHE_PREFIX("non-syntactic", "script"), uri, cachePath);
|
cachePath.AssignLiteral(JSSUB_CACHE_PREFIX("non-syntactic"));
|
||||||
} else {
|
} 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) {
|
static void ReportError(JSContext* cx, const nsACString& msg) {
|
||||||
|
|||||||
@@ -166,7 +166,32 @@ nsresult ResolveURI(nsIURI* in, nsIURI** out) {
|
|||||||
return NS_OK;
|
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;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult rv = ResolveURI(in, getter_AddRefs(uri));
|
nsresult rv = ResolveURI(in, getter_AddRefs(uri));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
@@ -194,7 +219,7 @@ static nsresult PathifyURIImpl(nsIURI* in, nsACString& out) {
|
|||||||
rv = jarURI->GetJARFile(getter_AddRefs(jarFileURI));
|
rv = jarURI->GetJARFile(getter_AddRefs(jarFileURI));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = PathifyURIImpl(jarFileURI, out);
|
rv = PathifyURI(jarFileURI, out);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsAutoCString path;
|
nsAutoCString path;
|
||||||
@@ -213,12 +238,5 @@ static nsresult PathifyURIImpl(nsIURI* in, nsACString& out) {
|
|||||||
return NS_OK;
|
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 scache
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -37,38 +37,7 @@ nsresult NewBufferFromStorageStream(nsIStorageStream* storageStream,
|
|||||||
|
|
||||||
nsresult ResolveURI(nsIURI* in, nsIURI** out);
|
nsresult ResolveURI(nsIURI* in, nsIURI** out);
|
||||||
|
|
||||||
// PathifyURI transforms uris into useful zip paths
|
nsresult PathifyURI(nsIURI* in, nsACString& out);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace scache
|
} // namespace scache
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user