зеркало из https://github.com/mozilla/gecko-dev.git
Bug 533038 - 1. Generalize manifest reading code and add api for reading manifests from jars, r=bsmedberg a=blocking-beta6
This commit is contained in:
Родитель
77bfcfd379
Коммит
ef808d0528
|
@ -142,13 +142,11 @@ public:
|
|||
, mPath(NULL)
|
||||
{ }
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
ManifestProcessingContext(NSLocationType aType, const char* aPath)
|
||||
ManifestProcessingContext(NSLocationType aType, nsILocalFile* aFile, const char* aPath)
|
||||
: mType(aType)
|
||||
, mFile(mozilla::OmnijarPath())
|
||||
, mFile(aFile)
|
||||
, mPath(aPath)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
~ManifestProcessingContext()
|
||||
{ }
|
||||
|
|
|
@ -78,8 +78,6 @@
|
|||
#include "nsIXULAppInfo.h"
|
||||
#include "nsIXULRuntime.h"
|
||||
|
||||
#include "mozilla/Omnijar.h"
|
||||
|
||||
#define UILOCALE_CMD_LINE_ARG "UILocale"
|
||||
|
||||
#define MATCH_OS_LOCALE_PREF "intl.locale.matchOS"
|
||||
|
@ -788,7 +786,6 @@ nsChromeRegistry::ManifestProcessingContext::GetManifestURI()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
if (mPath) {
|
||||
nsCOMPtr<nsIURI> fileURI;
|
||||
io->NewFileURI(mFile, getter_AddRefs(fileURI));
|
||||
|
@ -801,9 +798,7 @@ nsChromeRegistry::ManifestProcessingContext::GetManifestURI()
|
|||
|
||||
NS_NewURI(getter_AddRefs(mManifestURI), spec, NULL, NULL, io);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
else {
|
||||
io->NewFileURI(mFile, getter_AddRefs(mManifestURI));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,9 @@
|
|||
#define ZIP_TABSIZE 256
|
||||
#define ZIP_BUFLEN (4*1024) /* Used as output buffer when deflating items to a file */
|
||||
|
||||
#ifndef PL_ARENA_CONST_ALIGN_MASK
|
||||
#define PL_ARENA_CONST_ALIGN_MASK (sizeof(void*)-1)
|
||||
#endif
|
||||
#include "plarena.h"
|
||||
|
||||
#include "zlib.h"
|
||||
|
|
|
@ -374,6 +374,27 @@ XRE_API(nsresult,
|
|||
XRE_AddManifestLocation, (NSLocationType aType,
|
||||
nsILocalFile* aLocation))
|
||||
|
||||
/**
|
||||
* Register XPCOM components found in a JAR.
|
||||
* This is similar to XRE_AddManifestLocation except the file specified
|
||||
* must be a zip archive with a manifest named chrome.manifest
|
||||
* This method may be called at any time before or after XRE_main or
|
||||
* XRE_InitEmbedding.
|
||||
*
|
||||
* @param aFiles An array of files or directories.
|
||||
* @param aFileCount the number of items in the aFiles array.
|
||||
* @note appdir/components is registered automatically.
|
||||
*
|
||||
* NS_COMPONENT_LOCATION specifies a location to search for binary XPCOM
|
||||
* components as well as component/chrome manifest files.
|
||||
*
|
||||
* NS_SKIN_LOCATION specifies a location to search for chrome manifest files
|
||||
* which are only allowed to register only skin packages and style overlays.
|
||||
*/
|
||||
XRE_API(nsresult,
|
||||
XRE_AddJarManifestLocation, (NSLocationType aType,
|
||||
nsILocalFile* aLocation))
|
||||
|
||||
/**
|
||||
* Fire notifications to inform the toolkit about a new profile. This
|
||||
* method should be called after XRE_InitEmbedding if the embedder
|
||||
|
|
|
@ -68,10 +68,6 @@ CPPSRCS = \
|
|||
nsNativeComponentLoader.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_OMNIJAR
|
||||
CPPSRCS += nsManifestZIPLoader.cpp
|
||||
endif
|
||||
|
||||
SDK_XPIDLSRCS = \
|
||||
nsIClassInfo.idl \
|
||||
nsIComponentRegistrar.idl \
|
||||
|
|
|
@ -650,14 +650,12 @@ ParseManifest(NSLocationType type, nsILocalFile* file,
|
|||
ParseManifestCommon(type, file, mgrcx, chromecx, NULL, buf, aChromeOnly);
|
||||
}
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
void
|
||||
ParseManifest(NSLocationType type, const char* jarPath,
|
||||
ParseManifest(NSLocationType type, nsIZipReader* reader, const char* jarPath,
|
||||
char* buf, bool aChromeOnly)
|
||||
{
|
||||
nsComponentManagerImpl::ManifestProcessingContext mgrcx(type, jarPath, aChromeOnly);
|
||||
nsChromeRegistry::ManifestProcessingContext chromecx(type, jarPath);
|
||||
ParseManifestCommon(type, mozilla::OmnijarPath(), mgrcx, chromecx, jarPath,
|
||||
nsComponentManagerImpl::ManifestProcessingContext mgrcx(type, reader, jarPath, aChromeOnly);
|
||||
nsChromeRegistry::ManifestProcessingContext chromecx(type, mgrcx.mFile, jarPath);
|
||||
ParseManifestCommon(type, mgrcx.mFile, mgrcx, chromecx, jarPath,
|
||||
buf, aChromeOnly);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -42,14 +42,13 @@
|
|||
#include "nsChromeRegistry.h"
|
||||
|
||||
class nsILocalFile;
|
||||
class nsIZipReader;
|
||||
|
||||
void ParseManifest(NSLocationType type, nsILocalFile* file,
|
||||
char* buf, bool aChromeOnly);
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
void ParseManifest(NSLocationType type, const char* jarPath,
|
||||
char* buf, bool aChromeOnly);
|
||||
#endif
|
||||
void ParseManifest(NSLocationType type, nsIZipReader* reader,
|
||||
const char* jarPath, char* buf, bool aChromeOnly);
|
||||
|
||||
void LogMessage(const char* aMsg, ...);
|
||||
|
||||
|
|
|
@ -106,10 +106,9 @@
|
|||
#include <Path.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
#include "mozilla/Omnijar.h"
|
||||
#include "nsJAR.h"
|
||||
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
#endif
|
||||
|
||||
#include "prlog.h"
|
||||
|
||||
|
@ -353,9 +352,7 @@ nsresult nsComponentManagerImpl::Init()
|
|||
mContractIDs.Init(CONTRACTID_HASHTABLE_INITIAL_SIZE);
|
||||
mLoaderMap.Init();
|
||||
mKnownFileModules.Init();
|
||||
#ifdef MOZ_OMNIJAR
|
||||
mKnownJARModules.Init();
|
||||
#endif
|
||||
|
||||
mMon = nsAutoMonitor::NewMonitor("nsComponentManagerImpl");
|
||||
if (mMon == nsnull)
|
||||
|
@ -372,6 +369,7 @@ nsresult nsComponentManagerImpl::Init()
|
|||
ComponentLocation* cl = sModuleLocations->InsertElementAt(0);
|
||||
cl->type = NS_COMPONENT_LOCATION;
|
||||
cl->location = CloneAndAppend(appDir, NS_LITERAL_CSTRING("chrome.manifest"));
|
||||
cl->jar = false;
|
||||
|
||||
PRBool equals = PR_FALSE;
|
||||
appDir->Equals(greDir, &equals);
|
||||
|
@ -379,6 +377,7 @@ nsresult nsComponentManagerImpl::Init()
|
|||
cl = sModuleLocations->InsertElementAt(0);
|
||||
cl->type = NS_COMPONENT_LOCATION;
|
||||
cl->location = CloneAndAppend(greDir, NS_LITERAL_CSTRING("chrome.manifest"));
|
||||
cl->jar = false;
|
||||
}
|
||||
|
||||
PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG,
|
||||
|
@ -397,16 +396,36 @@ nsresult nsComponentManagerImpl::Init()
|
|||
RegisterModule((*sStaticModules)[i], NULL);
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
mManifestLoader = new nsManifestZIPLoader();
|
||||
|
||||
RegisterOmnijar("chrome.manifest", false);
|
||||
if (mozilla::OmnijarPath()) {
|
||||
nsCOMPtr<nsIZipReader> omnijarReader = new nsJAR();
|
||||
rv = omnijarReader->Open(mozilla::OmnijarPath());
|
||||
if (NS_SUCCEEDED(rv))
|
||||
RegisterJarManifest(omnijarReader, "chrome.manifest", false);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (PRUint32 i = 0; i < sModuleLocations->Length(); ++i) {
|
||||
ComponentLocation& l = sModuleLocations->ElementAt(i);
|
||||
RegisterManifestFile(l.type, l.location, false);
|
||||
if (!l.jar) {
|
||||
RegisterManifestFile(l.type, l.location, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIZipReader> reader = do_CreateInstance(kZipReaderCID, &rv);
|
||||
rv = reader->Open(l.location);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
RegisterJarManifest(reader, "chrome.manifest", false);
|
||||
}
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
if (mozilla::OmnijarPath()) {
|
||||
cl = sModuleLocations->InsertElementAt(0);
|
||||
cl->type = NS_COMPONENT_LOCATION;
|
||||
cl->location = mozilla::OmnijarPath();
|
||||
cl->jar = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCategoryManager::GetSingleton()->SuppressNotifications(false);
|
||||
|
||||
mStatus = NORMAL;
|
||||
|
@ -522,16 +541,27 @@ GetExtension(nsILocalFile* file)
|
|||
return extension;
|
||||
}
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
void
|
||||
nsComponentManagerImpl::RegisterOmnijar(const char* aPath, bool aChromeOnly)
|
||||
static already_AddRefed<nsIInputStream>
|
||||
LoadEntry(nsIZipReader* aReader, const char* aName)
|
||||
{
|
||||
if (!mozilla::OmnijarPath())
|
||||
return;
|
||||
if (!aReader)
|
||||
return NULL;
|
||||
|
||||
nsCOMPtr<nsIInputStream> is = mManifestLoader->LoadEntry(aPath);
|
||||
nsCOMPtr<nsIInputStream> is;
|
||||
nsresult rv = aReader->GetInputStream(aName, getter_AddRefs(is));
|
||||
if (NS_FAILED(rv))
|
||||
return NULL;
|
||||
|
||||
return is.forget();
|
||||
}
|
||||
|
||||
void
|
||||
nsComponentManagerImpl::RegisterJarManifest(nsIZipReader* aReader,
|
||||
const char* aPath, bool aChromeOnly)
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> is = LoadEntry(aReader, aPath);
|
||||
if (!is) {
|
||||
LogMessage("Could not find omnijar manifest entry '%s'.", aPath);
|
||||
LogMessage("Could not find jar manifest entry '%s'.", aPath);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -560,9 +590,9 @@ nsComponentManagerImpl::RegisterOmnijar(const char* aPath, bool aChromeOnly)
|
|||
|
||||
whole[flen] = '\0';
|
||||
|
||||
ParseManifest(NS_COMPONENT_LOCATION, aPath, whole, aChromeOnly);
|
||||
ParseManifest(NS_COMPONENT_LOCATION, aReader, aPath,
|
||||
whole, aChromeOnly);
|
||||
}
|
||||
#endif // MOZ_OMNIJAR
|
||||
|
||||
namespace {
|
||||
struct AutoCloseFD
|
||||
|
@ -636,7 +666,6 @@ TranslateSlashes(char* path)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
static void
|
||||
AppendFileToManifestPath(nsCString& path,
|
||||
const char* file)
|
||||
|
@ -649,23 +678,19 @@ AppendFileToManifestPath(nsCString& path,
|
|||
|
||||
path.Append(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nsComponentManagerImpl::ManifestManifest(ManifestProcessingContext& cx, int lineno, char *const * argv)
|
||||
{
|
||||
char* file = argv[0];
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
if (cx.mPath) {
|
||||
nsCAutoString manifest(cx.mPath);
|
||||
AppendFileToManifestPath(manifest, file);
|
||||
|
||||
RegisterOmnijar(manifest.get(), cx.mChromeOnly);
|
||||
RegisterJarManifest(cx.mReader, manifest.get(), cx.mChromeOnly);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
else {
|
||||
#ifdef TRANSLATE_SLASHES
|
||||
TranslateSlashes(file);
|
||||
#endif
|
||||
|
@ -686,14 +711,12 @@ nsComponentManagerImpl::ManifestManifest(ManifestProcessingContext& cx, int line
|
|||
void
|
||||
nsComponentManagerImpl::ManifestBinaryComponent(ManifestProcessingContext& cx, int lineno, char *const * argv)
|
||||
{
|
||||
#ifdef MOZ_OMNIJAR
|
||||
if (cx.mPath) {
|
||||
NS_WARNING("Cannot load binary components from the omnijar.");
|
||||
NS_WARNING("Cannot load binary components from a jar.");
|
||||
LogMessageWithContext(cx.mFile, cx.mPath, lineno,
|
||||
"Cannot load binary components from the omnijar.");
|
||||
"Cannot load binary components from a jar.");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
char* file = argv[0];
|
||||
|
||||
|
@ -723,24 +746,21 @@ nsComponentManagerImpl::ManifestXPT(ManifestProcessingContext& cx, int lineno, c
|
|||
{
|
||||
char* file = argv[0];
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
if (cx.mPath) {
|
||||
nsCAutoString manifest(cx.mPath);
|
||||
AppendFileToManifestPath(manifest, file);
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream =
|
||||
mManifestLoader->LoadEntry(manifest.get());
|
||||
LoadEntry(cx.mReader, manifest.get());
|
||||
if (!stream) {
|
||||
NS_WARNING("Failed to load omnijar XPT file.");
|
||||
NS_WARNING("Failed to load XPT file in a jar.");
|
||||
return;
|
||||
}
|
||||
|
||||
xptiInterfaceInfoManager::GetSingleton()
|
||||
->RegisterInputStream(stream);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
else {
|
||||
#ifdef TRANSLATE_SLASHES
|
||||
TranslateSlashes(file);
|
||||
#endif
|
||||
|
@ -793,20 +813,22 @@ nsComponentManagerImpl::ManifestComponent(ManifestProcessingContext& cx, int lin
|
|||
|
||||
KnownModule* km;
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
if (cx.mPath) {
|
||||
nsCAutoString manifest(cx.mPath);
|
||||
AppendFileToManifestPath(manifest, file);
|
||||
|
||||
km = mKnownJARModules.Get(manifest);
|
||||
nsCAutoString hash;
|
||||
cx.mFile->GetNativePath(hash);
|
||||
hash.AppendLiteral("|");
|
||||
hash.Append(manifest);
|
||||
|
||||
km = mKnownJARModules.Get(hash);
|
||||
if (!km) {
|
||||
km = new KnownModule(manifest);
|
||||
mKnownJARModules.Put(manifest, km);
|
||||
km = new KnownModule(cx.mFile, manifest);
|
||||
mKnownJARModules.Put(hash, km);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
else {
|
||||
#ifdef TRANSLATE_SLASHES
|
||||
TranslateSlashes(file);
|
||||
#endif
|
||||
|
@ -881,13 +903,19 @@ nsComponentManagerImpl::ManifestCategory(ManifestProcessingContext& cx, int line
|
|||
void
|
||||
nsComponentManagerImpl::RereadChromeManifests()
|
||||
{
|
||||
#ifdef MOZ_OMNIJAR
|
||||
RegisterOmnijar("chrome.manifest", true);
|
||||
#endif
|
||||
|
||||
for (PRUint32 i = 0; i < sModuleLocations->Length(); ++i) {
|
||||
ComponentLocation& l = sModuleLocations->ElementAt(i);
|
||||
RegisterManifestFile(l.type, l.location, true);
|
||||
if (!l.jar) {
|
||||
RegisterManifestFile(l.type, l.location, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIZipReader> reader = do_CreateInstance(kZipReaderCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = reader->Open(l.location);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
RegisterJarManifest(reader, "chrome.manifest", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -896,14 +924,11 @@ nsComponentManagerImpl::KnownModule::EnsureLoader()
|
|||
{
|
||||
if (!mLoader) {
|
||||
nsCString extension;
|
||||
#if MOZ_OMNIJAR
|
||||
if (!mPath.IsEmpty()) {
|
||||
extension = mPath;
|
||||
CutExtension(extension);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
else {
|
||||
extension = GetExtension(mFile);
|
||||
}
|
||||
|
||||
|
@ -921,11 +946,9 @@ nsComponentManagerImpl::KnownModule::Load()
|
|||
if (!EnsureLoader())
|
||||
return false;
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
if (!mPath.IsEmpty())
|
||||
mModule = mLoader->LoadModuleFromJAR(mozilla::OmnijarPath(), mPath);
|
||||
mModule = mLoader->LoadModuleFromJAR(mFile, mPath);
|
||||
else
|
||||
#endif
|
||||
mModule = mLoader->LoadModule(mFile);
|
||||
|
||||
if (!mModule) {
|
||||
|
@ -950,14 +973,13 @@ nsCString
|
|||
nsComponentManagerImpl::KnownModule::Description() const
|
||||
{
|
||||
nsCString s;
|
||||
#ifdef MOZ_OMNIJAR
|
||||
if (!mPath.IsEmpty()) {
|
||||
s.AssignLiteral("omnijar:");
|
||||
mFile->GetNativePath(s);
|
||||
s.Insert(NS_LITERAL_CSTRING("jar:"), 0);
|
||||
s.AppendLiteral("!/");
|
||||
s.Append(mPath);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (mFile)
|
||||
else if (mFile)
|
||||
mFile->GetNativePath(s);
|
||||
else
|
||||
s = "<static module>";
|
||||
|
@ -979,9 +1001,7 @@ nsresult nsComponentManagerImpl::Shutdown(void)
|
|||
mContractIDs.Clear();
|
||||
mFactories.Clear(); // XXX release the objects, don't just clear
|
||||
mLoaderMap.Clear();
|
||||
#ifdef MOZ_OMNIJAR
|
||||
mKnownJARModules.Clear();
|
||||
#endif
|
||||
mKnownFileModules.Clear();
|
||||
mKnownStaticModules.Clear();
|
||||
|
||||
|
@ -1199,8 +1219,7 @@ nsComponentManagerImpl::CreateInstance(const nsCID &aClass,
|
|||
rv = NS_ERROR_SERVICE_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// Translate error values
|
||||
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
}
|
||||
|
@ -1287,8 +1306,7 @@ nsComponentManagerImpl::CreateInstanceByContractID(const char *aContractID,
|
|||
rv = NS_ERROR_SERVICE_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// Translate error values
|
||||
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
}
|
||||
|
@ -1992,6 +2010,7 @@ XRE_AddManifestLocation(NSLocationType aType, nsILocalFile* aLocation)
|
|||
nsComponentManagerImpl::sModuleLocations->AppendElement();
|
||||
c->type = aType;
|
||||
c->location = aLocation;
|
||||
c->jar = false;
|
||||
|
||||
if (nsComponentManagerImpl::gComponentManager &&
|
||||
nsComponentManagerImpl::NORMAL == nsComponentManagerImpl::gComponentManager->mStatus)
|
||||
|
@ -1999,3 +2018,29 @@ XRE_AddManifestLocation(NSLocationType aType, nsILocalFile* aLocation)
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
XRE_AddJarManifestLocation(NSLocationType aType, nsILocalFile* aLocation)
|
||||
{
|
||||
nsComponentManagerImpl::InitializeModuleLocations();
|
||||
nsComponentManagerImpl::ComponentLocation* c =
|
||||
nsComponentManagerImpl::sModuleLocations->AppendElement();
|
||||
c->type = aType;
|
||||
c->location = aLocation;
|
||||
c->jar = true;
|
||||
|
||||
if (!nsComponentManagerImpl::gComponentManager ||
|
||||
nsComponentManagerImpl::NORMAL != nsComponentManagerImpl::gComponentManager->mStatus)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIZipReader> reader = do_CreateInstance(kZipReaderCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = reader->Open(c->location);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
nsComponentManagerImpl::gComponentManager->RegisterJarManifest(reader, "chrome.manifest", false);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,10 +66,8 @@
|
|||
#include "nsClassHashtable.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
#include "mozilla/Omnijar.h"
|
||||
#include "nsManifestZIPLoader.h"
|
||||
#endif
|
||||
#include "nsIZipReader.h"
|
||||
|
||||
struct nsFactoryEntry;
|
||||
class nsIServiceManager;
|
||||
|
@ -91,14 +89,6 @@ extern const char fileSizeValueName[];
|
|||
extern const char nativeComponentType[];
|
||||
extern const char staticComponentType[];
|
||||
|
||||
typedef int LoaderType;
|
||||
|
||||
// Predefined loader types.
|
||||
#define NS_LOADER_TYPE_NATIVE -1
|
||||
#define NS_LOADER_TYPE_STATIC -2
|
||||
#define NS_LOADER_TYPE_JAR -3
|
||||
#define NS_LOADER_TYPE_INVALID -4
|
||||
|
||||
#ifdef DEBUG
|
||||
#define XPCOM_CHECK_PENDING_CIDS
|
||||
#endif
|
||||
|
@ -169,10 +159,12 @@ public:
|
|||
{
|
||||
NSLocationType type;
|
||||
nsCOMPtr<nsILocalFile> location;
|
||||
bool jar;
|
||||
};
|
||||
|
||||
static nsTArray<const mozilla::Module*>* sStaticModules;
|
||||
static nsTArray<ComponentLocation>* sModuleLocations;
|
||||
static nsTArray<ComponentLocation>* sJarModuleLocations;
|
||||
|
||||
nsNativeModuleLoader mNativeModuleLoader;
|
||||
|
||||
|
@ -197,16 +189,14 @@ public:
|
|||
, mFailed(false)
|
||||
{ }
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
KnownModule(const nsACString& aPath)
|
||||
KnownModule(nsILocalFile* aFile, const nsACString& aPath)
|
||||
: mModule(NULL)
|
||||
, mFile(NULL)
|
||||
, mFile(aFile)
|
||||
, mPath(aPath)
|
||||
, mLoader(NULL)
|
||||
, mLoaded(false)
|
||||
, mFailed(false)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
~KnownModule()
|
||||
{
|
||||
|
@ -231,9 +221,7 @@ public:
|
|||
private:
|
||||
const mozilla::Module* mModule;
|
||||
nsCOMPtr<nsILocalFile> mFile;
|
||||
#ifdef MOZ_OMNIJAR
|
||||
nsCString mPath;
|
||||
#endif
|
||||
nsCOMPtr<mozilla::ModuleLoader> mLoader;
|
||||
bool mLoaded;
|
||||
bool mFailed;
|
||||
|
@ -243,9 +231,8 @@ public:
|
|||
// referenced by pointer from the factory entries.
|
||||
nsTArray< nsAutoPtr<KnownModule> > mKnownStaticModules;
|
||||
nsClassHashtable<nsHashableHashKey, KnownModule> mKnownFileModules;
|
||||
#ifdef MOZ_OMNIJAR
|
||||
// The key is a string in this format "<jar path>|<path within jar>"
|
||||
nsClassHashtable<nsCStringHashKey, KnownModule> mKnownJARModules;
|
||||
#endif
|
||||
|
||||
void RegisterModule(const mozilla::Module* aModule,
|
||||
nsILocalFile* aFile);
|
||||
|
@ -253,9 +240,8 @@ public:
|
|||
KnownModule* aModule);
|
||||
void RegisterContractID(const mozilla::Module::ContractIDEntry* aEntry);
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
void RegisterOmnijar(const char* aPath, bool aChromeOnly);
|
||||
#endif
|
||||
void RegisterJarManifest(nsIZipReader* aReader,
|
||||
const char* aPath, bool aChromeOnly);
|
||||
|
||||
void RegisterManifestFile(NSLocationType aType, nsILocalFile* aFile,
|
||||
bool aChromeOnly);
|
||||
|
@ -269,19 +255,23 @@ public:
|
|||
, mChromeOnly(aChromeOnly)
|
||||
{ }
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
ManifestProcessingContext(NSLocationType aType, const char* aPath, bool aChromeOnly)
|
||||
ManifestProcessingContext(NSLocationType aType, nsIZipReader* aReader, const char* aPath, bool aChromeOnly)
|
||||
: mType(aType)
|
||||
, mFile(mozilla::OmnijarPath())
|
||||
, mReader(aReader)
|
||||
, mPath(aPath)
|
||||
, mChromeOnly(aChromeOnly)
|
||||
{ }
|
||||
#endif
|
||||
{
|
||||
nsCOMPtr<nsIFile> file;
|
||||
aReader->GetFile(getter_AddRefs(file));
|
||||
nsCOMPtr<nsILocalFile> localfile = do_QueryInterface(file);
|
||||
mFile = localfile;
|
||||
}
|
||||
|
||||
~ManifestProcessingContext() { }
|
||||
|
||||
NSLocationType mType;
|
||||
nsILocalFile* mFile;
|
||||
nsIZipReader* mReader;
|
||||
const char* mPath;
|
||||
bool mChromeOnly;
|
||||
};
|
||||
|
@ -321,10 +311,6 @@ public:
|
|||
|
||||
private:
|
||||
~nsComponentManagerImpl();
|
||||
|
||||
#ifdef MOZ_OMNIJAR
|
||||
nsAutoPtr<nsManifestZIPLoader> mManifestLoader;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the XPT zip reader.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
||||
class nsManifestZIPLoader
|
||||
{
|
||||
public:
|
||||
nsManifestZIPLoader();
|
||||
~nsManifestZIPLoader();
|
||||
|
||||
already_AddRefed<nsIInputStream> LoadEntry(const char* name);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIZipReader> mZipReader;
|
||||
};
|
||||
|
|
@ -133,6 +133,12 @@ nsresult TestRegular()
|
|||
kCoreServiceA_CID, kExtServiceA_CID);
|
||||
}
|
||||
|
||||
nsresult TestJar()
|
||||
{
|
||||
return execRegOrderTest("TestJar", SERVICE_B_CONTRACT_ID,
|
||||
kCoreServiceB_CID, kExtServiceB_CID);
|
||||
}
|
||||
|
||||
bool TestContractFirst()
|
||||
{
|
||||
nsCOMPtr<nsIComponentRegistrar> r;
|
||||
|
@ -167,7 +173,8 @@ GetRegDirectory(const char* basename, const char* dirname, const char* leafname)
|
|||
return NULL;
|
||||
|
||||
f->AppendNative(nsDependentCString(dirname));
|
||||
f->AppendNative(nsDependentCString(leafname));
|
||||
if (leafname)
|
||||
f->AppendNative(nsDependentCString(leafname));
|
||||
return f.forget();
|
||||
}
|
||||
|
||||
|
@ -188,6 +195,8 @@ int main(int argc, char** argv)
|
|||
nsCOMPtr<nsILocalFile>(GetRegDirectory(regPath, "core", "component.manifest")));
|
||||
XRE_AddManifestLocation(NS_COMPONENT_LOCATION,
|
||||
nsCOMPtr<nsILocalFile>(GetRegDirectory(regPath, "extension", "extComponent.manifest")));
|
||||
XRE_AddJarManifestLocation(NS_COMPONENT_LOCATION,
|
||||
nsCOMPtr<nsILocalFile>(GetRegDirectory(regPath, "extension2.jar", NULL)));
|
||||
ScopedXPCOM xpcom("RegistrationOrder");
|
||||
if (xpcom.failed())
|
||||
return 1;
|
||||
|
@ -196,6 +205,9 @@ int main(int argc, char** argv)
|
|||
if (NS_FAILED(TestRegular()))
|
||||
rv = 1;
|
||||
|
||||
if (NS_FAILED(TestJar()))
|
||||
rv = 1;
|
||||
|
||||
if (!TestContractFirst())
|
||||
rv = 1;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
component {56ab1cd4-ac44-4f86-8104-171f8b8f2fc7} component.js
|
||||
component {d04d1298-6dac-459b-a13b-bcab235730a0} component2.js
|
||||
contract @mozilla.org/RegTestServiceA;1 {56ab1cd4-ac44-4f86-8104-171f8b8f2fc7}
|
||||
contract @mozilla.org/RegTestServiceB;1 {d04d1298-6dac-459b-a13b-bcab235730a0}
|
||||
|
||||
contract @mozilla.org/RegTestOrderC;1 {ada15884-bb89-473c-8b50-dcfbb8447ff4}
|
||||
component {ada15884-bb89-473c-8b50-dcfbb8447ff4} missing.js
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -12,20 +13,19 @@
|
|||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the XPT zip reader.
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* Kathleen Brade <brade@pearlcrescent.com>
|
||||
* Mark Smith <mcs@pearlcrescent.com>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
* Alec Flett <alecf@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
|
@ -37,33 +37,35 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#include "nsManifestZIPLoader.h"
|
||||
#include "nsJAR.h"
|
||||
#include "mozilla/Omnijar.h"
|
||||
|
||||
nsManifestZIPLoader::nsManifestZIPLoader()
|
||||
: mZipReader(new nsJAR())
|
||||
var gRegTestCoreComponent =
|
||||
{
|
||||
nsresult rv = mZipReader->Open(mozilla::OmnijarPath());
|
||||
if (NS_FAILED(rv))
|
||||
mZipReader = NULL;
|
||||
}
|
||||
|
||||
nsManifestZIPLoader::~nsManifestZIPLoader()
|
||||
{
|
||||
}
|
||||
|
||||
already_AddRefed<nsIInputStream>
|
||||
nsManifestZIPLoader::LoadEntry(const char* aName)
|
||||
{
|
||||
if (!mZipReader)
|
||||
return NULL;
|
||||
|
||||
nsCOMPtr<nsIInputStream> is;
|
||||
nsresult rv = mZipReader->GetInputStream(aName, getter_AddRefs(is));
|
||||
if (NS_FAILED(rv))
|
||||
return NULL;
|
||||
|
||||
return is.forget();
|
||||
/* nsISupports implementation. */
|
||||
QueryInterface: function (aIID)
|
||||
{
|
||||
if (!aIID.equals(Components.interfaces.nsISupports) &&
|
||||
!aIID.equals(Components.interfaces.nsIFactory))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/* nsIFactory implementation. */
|
||||
createInstance: function (aOuter, aIID)
|
||||
{
|
||||
if (null != aOuter)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
return this.QueryInterface(aIID);
|
||||
},
|
||||
|
||||
lockFactory: function (aDoLock) {}
|
||||
};
|
||||
|
||||
const kClassID = Components.ID("{d04d1298-6dac-459b-a13b-bcab235730a0}");
|
||||
|
||||
function NSGetFactory(aClassID) {
|
||||
if (!aClassID.equals(kClassID))
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
return gRegTestCoreComponent;
|
||||
}
|
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче