diff --git a/mozilla/config/rules.mk b/mozilla/config/rules.mk index a0cb5bcb30b..2657d190448 100644 --- a/mozilla/config/rules.mk +++ b/mozilla/config/rules.mk @@ -535,6 +535,14 @@ endif endif endif +# Dependent libs +ifdef IS_COMPONENT +DEPENDENT_LIBS = $(patsubst -l%,$(LIB_PREFIX)%$(DLL_SUFFIX),$(filter -l%, $(EXTRA_DSO_LDOPTS))) +ifneq (,$(strip $(DEPENDENT_LIBS))) +DEFINES += -DDEPENDENT_LIBS="$(foreach f,$(DEPENDENT_LIBS),\"${f}\",)" +endif +endif + ################################################################################ all:: @@ -1680,6 +1688,7 @@ ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $ @echo "SHARED_LIBS = $(SHARED_LIBS)" @echo "EXTRA_DSO_LIBS = $(EXTRA_DSO_LIBS)" @echo "EXTRA_DSO_LDOPTS = $(EXTRA_DSO_LDOPTS)" + @echo "DEPENDENT_LIBS = $(DEPENDENT_LIBS)" @echo -------------------------------------------------------------------------------- endif +$(LOOP_OVER_MOZ_DIRS) diff --git a/mozilla/xpcom/build/dlldeps.cpp b/mozilla/xpcom/build/dlldeps.cpp index 2dda0eefa5f..0d9c7d15db2 100644 --- a/mozilla/xpcom/build/dlldeps.cpp +++ b/mozilla/xpcom/build/dlldeps.cpp @@ -148,7 +148,6 @@ void XXXNeverCalled() xptc_dummy2(); XPTI_GetInterfaceInfoManager(); NS_NewGenericFactory(NULL, NULL); - NS_NewGenericModule(NULL, 0, NULL, NULL, NULL); NS_NewGenericModule2(NULL, NULL); NS_NewHashtableEnumerator(NULL, NULL, NULL, NULL); nsCWeakProxy(0, 0); diff --git a/mozilla/xpcom/components/Makefile.in b/mozilla/xpcom/components/Makefile.in index 06cfdbe1abe..1498f15437a 100644 --- a/mozilla/xpcom/components/Makefile.in +++ b/mozilla/xpcom/components/Makefile.in @@ -70,16 +70,17 @@ XPIDLSRCS = \ nsIComponentLoaderManager.idl \ nsIComponentManagerObsolete.idl \ nsIRegistry.idl \ + nsINativeComponentLoader.idl \ $(NULL) SDK_XPIDLSRCS = \ - nsIClassInfo.idl \ - nsIComponentRegistrar.idl \ - nsIFactory.idl \ - nsIModule.idl \ - nsIServiceManager.idl \ - nsIComponentManager.idl \ - nsICategoryManager.idl \ + nsIClassInfo.idl \ + nsIComponentRegistrar.idl \ + nsIFactory.idl \ + nsIModule.idl \ + nsIServiceManager.idl \ + nsIComponentManager.idl \ + nsICategoryManager.idl \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index 364afc4156d..a70ba304e14 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -61,6 +61,8 @@ #include "nsLocalFile.h" #include "nsNativeComponentLoader.h" #include "nsRegistry.h" +#include "nsReadableUtils.h" +#include "nsString.h" #include "nsXPIDLString.h" #include "prcmon.h" #include "xptinfo.h" // this after nsISupports, to pick up IID so that xpt stuff doesn't try to define it itself... @@ -119,7 +121,7 @@ const char versionValueName[]="VersionString"; const static char XPCOM_ABSCOMPONENT_PREFIX[] = "abs:"; const static char XPCOM_RELCOMPONENT_PREFIX[] = "rel:"; -const char XPCOM_LIB_PREFIX[] = "lib:"; +const static char XPCOM_GRECOMPONENT_PREFIX[] = "gre:"; const static char persistentRegistryFilename[] = "compreg.dat"; const static char persistentRegistryTempFilename[] = "compreg.tmp"; @@ -670,7 +672,8 @@ ConvertContractIDKeyToString(PLDHashTable *table, } // this is safe to call during InitXPCOM -static nsresult GetDefaultComponentsDirectory(nsIFile** aDirectory) +static nsresult GetLocationFromDirectoryService(const char* prop, + nsIFile** aDirectory) { nsCOMPtr directoryService; nsDirectoryService::Create(nsnull, @@ -680,11 +683,12 @@ static nsresult GetDefaultComponentsDirectory(nsIFile** aDirectory) if (!directoryService) return NS_ERROR_FAILURE; - return directoryService->Get(NS_XPCOM_COMPONENT_DIR, + return directoryService->Get(prop, NS_GET_IID(nsIFile), (void**)aDirectory); } + //////////////////////////////////////////////////////////////////////////////// // nsComponentManagerImpl //////////////////////////////////////////////////////////////////////////////// @@ -694,7 +698,9 @@ nsComponentManagerImpl::nsComponentManagerImpl() : mMon(NULL), mNativeComponentLoader(0), +#ifdef ENABLE_STATIC_COMPONENT_LOADER mStaticComponentLoader(0), +#endif mShuttingDown(NS_SHUTDOWN_NEVERHAPPENED), mLoaderData(nsnull), mRegistryDirty(PR_FALSE) @@ -714,8 +720,6 @@ nsresult nsComponentManagerImpl::Init(void) if (nsComponentManagerLog == nsnull) { nsComponentManagerLog = PR_NewLogModule("nsComponentManager"); - PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, - ("xpcom-log-version : " NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING)); } // Initialize our arena @@ -798,8 +802,9 @@ nsresult nsComponentManagerImpl::Init(void) mStaticComponentLoader->Init(this, nsnull); } #endif + NR_StartupRegistry(); - GetDefaultComponentsDirectory(getter_AddRefs(mComponentsDir)); + GetLocationFromDirectoryService(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(mComponentsDir)); if (!mComponentsDir) return NS_ERROR_OUT_OF_MEMORY; @@ -810,13 +815,28 @@ nsresult nsComponentManagerImpl::Init(void) mComponentsOffset = componentDescriptor.Length(); - NR_StartupRegistry(); + GetLocationFromDirectoryService(NS_GRE_COMPONENT_DIR, getter_AddRefs(mGREComponentsDir)); + if (mGREComponentsDir) { + nsresult rv = mGREComponentsDir->GetNativePath(componentDescriptor); + if (NS_FAILED(rv)) { + NS_WARNING("No GRE component manager"); + return rv; + } + mGREComponentsOffset = componentDescriptor.Length(); + } + PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS, ("nsComponentManager: Initialized.")); return NS_OK; } +PRIntn PR_CALLBACK AutoRegEntryDestroy(nsHashKey *aKey, void *aData, void* aClosure) +{ + delete (AutoRegEntry*)aData; + return kHashEnumerateNext; +} + nsresult nsComponentManagerImpl::Shutdown(void) { PR_ASSERT(mShuttingDown == NS_SHUTDOWN_NEVERHAPPENED); @@ -840,11 +860,8 @@ nsresult nsComponentManagerImpl::Shutdown(void) #endif } } - for (i = mAutoRegEntries.Count() - 1; i >= 0; i--) { - AutoRegEntry* entry = NS_STATIC_CAST(AutoRegEntry*, mAutoRegEntries[i]); - delete entry; - mAutoRegEntries.RemoveElementAt(i); - } + + mAutoRegEntries.Reset(AutoRegEntryDestroy); // Release all cached factories if (mContractIDs.ops) { @@ -917,14 +934,16 @@ NS_IMPL_THREADSAFE_ISUPPORTS8(nsComponentManagerImpl, nsresult nsComponentManagerImpl::GetInterface(const nsIID & uuid, void **result) { - if (uuid.Equals(NS_GET_IID(nsIServiceManager))) + if (uuid.Equals(NS_GET_IID(nsINativeComponentLoader))) { - *result = NS_STATIC_CAST(nsIServiceManager*, this); - NS_ADDREF_THIS(); - return NS_OK; + if (!mNativeComponentLoader) + return NS_ERROR_NOT_INITIALIZED; + + return mNativeComponentLoader->QueryInterface(uuid, result); } - // fall through to QI as anything QIable is a superset of what canbe + NS_WARNING("This isn't supported"); + // fall through to QI as anything QIable is a superset of what can be // got via the GetInterface() return QueryInterface(uuid, result); } @@ -941,10 +960,12 @@ AutoRegEntry::AutoRegEntry(const char* name, PRInt64* modDate) { mName = PL_strdup(name); mModDate = *modDate; + mData = nsnull; } AutoRegEntry::~AutoRegEntry() { if (mName) PL_strfree(mName); + if (mData) PL_strfree(mData); } PRBool @@ -953,6 +974,19 @@ AutoRegEntry::Modified(PRInt64 *date) return !LL_EQ(*date, mModDate); } +void +AutoRegEntry::SetOptionalData(const char* data) +{ + if (mData) + PL_strfree(mData); + + if (!data) { + mData = nsnull; + return; + } + + mData = PL_strdup(data); +} static PRBool ReadSectionHeader(nsManifestLineReader& reader, const char *token) @@ -1084,8 +1118,9 @@ nsComponentManagerImpl::ReadPersistentRegistry() if (!reader.NextLine()) break; - //name,last_modification_date - if (2 != reader.ParseLine(values, lengths, 2)) + //name,last_modification_date[,optionaldata] + int parts = reader.ParseLine(values, lengths, 3); + if (2 > parts) break; PRInt64 a = nsCRT::atoll(values[1]); @@ -1094,7 +1129,11 @@ nsComponentManagerImpl::ReadPersistentRegistry() if (!entry) return NS_ERROR_OUT_OF_MEMORY; - mAutoRegEntries.AppendElement(entry); + if (parts == 3) + entry->SetOptionalData(values[2]); + + nsCStringKey key((const char*)values[0]); + mAutoRegEntries.Put(&key, entry); } if (ReadSectionHeader(reader, "CLASSIDS")) @@ -1282,18 +1321,20 @@ ClassIDWriter(PLDHashTable *table, return PL_DHASH_NEXT; } -PR_STATIC_CALLBACK(PRBool) -AutoRegEntryWriter(void* aElement, void *aData) +PRIntn PR_CALLBACK +AutoRegEntryWriter(nsHashKey *aKey, void *aData, void* aClosure) { - PRFileDesc* fd = (PRFileDesc*) aData; - AutoRegEntry* entry = (AutoRegEntry*) aElement; - - //name,last_modification_date - PR_fprintf(fd, - "%s,%lld\n", - entry->GetName(), - entry->GetDate()); + PRFileDesc* fd = (PRFileDesc*) aClosure; + AutoRegEntry* entry = (AutoRegEntry*) aData; + const char* extraData = entry->GetOptionalData(); + const char *fmt; + if (extraData) + fmt = "%s,%lld,%s\n"; + else + fmt = "%s,%lld\n"; + PR_fprintf(fd, fmt, entry->GetName(), entry->GetDate(), extraData); + return PR_TRUE; } @@ -1400,7 +1441,7 @@ nsComponentManagerImpl::WritePersistentRegistry() if (!PR_fprintf(fd, "\n[COMPONENTS]\n")) goto out; - mAutoRegEntries.EnumerateForwards(AutoRegEntryWriter, (void*)fd); + mAutoRegEntries.Enumerate(AutoRegEntryWriter, (void*)fd); PersistentWriterArgs args; args.mFD = fd; @@ -1826,6 +1867,7 @@ nsComponentManagerImpl::CreateInstance(const nsCID &aClass, rv = NS_ERROR_FACTORY_NOT_REGISTERED; } + if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS)) { char *buf = aClass.ToString(); @@ -1850,9 +1892,9 @@ nsComponentManagerImpl::CreateInstance(const nsCID &aClass, */ nsresult nsComponentManagerImpl::CreateInstanceByContractID(const char *aContractID, - nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) + nsISupports *aDelegate, + const nsIID &aIID, + void **aResult) { // test this first, since there's no point in creating a component during // shutdown -- whether it's available or not would depend on the order it @@ -2373,13 +2415,6 @@ MakeRegistryName(const char *aDllName, const char *prefix, char **regName) return NS_OK; } -nsresult -nsComponentManagerImpl::RegistryNameForLib(const char *aLibName, - char **aRegistryName) -{ - return MakeRegistryName(aLibName, XPCOM_LIB_PREFIX, aRegistryName); -} - nsresult nsComponentManagerImpl::RegistryLocationForSpec(nsIFile *aSpec, char **aRegistryName) @@ -2394,30 +2429,42 @@ nsComponentManagerImpl::RegistryLocationForSpec(nsIFile *aSpec, return NS_OK; } + + // First check to see if this component is in the application + // components directory PRBool containedIn; mComponentsDir->Contains(aSpec, PR_TRUE, &containedIn); - nsCAutoString persistentDescriptor; + nsCAutoString nativePathString; if (containedIn){ - rv = aSpec->GetNativePath(persistentDescriptor); + rv = aSpec->GetNativePath(nativePathString); if (NS_FAILED(rv)) return rv; - const char* relativeLocation = persistentDescriptor.get() + mComponentsOffset + 1; + const char* relativeLocation = nativePathString.get() + mComponentsOffset + 1; + return MakeRegistryName(relativeLocation, XPCOM_RELCOMPONENT_PREFIX, aRegistryName); + } - rv = MakeRegistryName(relativeLocation, XPCOM_RELCOMPONENT_PREFIX, - aRegistryName); - } else { - /* absolute names include volume info on Mac, so persistent descriptor */ - rv = aSpec->GetNativePath(persistentDescriptor); + // Next check to see if this component is in the GRE + // components directory + + mGREComponentsDir->Contains(aSpec, PR_TRUE, &containedIn); + + if (containedIn){ + rv = aSpec->GetNativePath(nativePathString); if (NS_FAILED(rv)) return rv; - rv = MakeRegistryName(persistentDescriptor.get(), XPCOM_ABSCOMPONENT_PREFIX, - aRegistryName); - } + + const char* relativeLocation = nativePathString.get() + mGREComponentsOffset + 1; + return MakeRegistryName(relativeLocation, XPCOM_GRECOMPONENT_PREFIX, aRegistryName); + } - return rv; + /* absolute names include volume info on Mac, so persistent descriptor */ + rv = aSpec->GetNativePath(nativePathString); + if (NS_FAILED(rv)) + return rv; + return MakeRegistryName(nativePathString.get(), XPCOM_ABSCOMPONENT_PREFIX, aRegistryName); } nsresult @@ -2455,6 +2502,22 @@ nsComponentManagerImpl::SpecForRegistryLocation(const char *aLocation, *aSpec = file; return rv; } + + if (!strncmp(aLocation, XPCOM_GRECOMPONENT_PREFIX, 4)) { + + if (!mGREComponentsDir) + return NS_ERROR_NOT_INITIALIZED; + + nsILocalFile* file = nsnull; + rv = mGREComponentsDir->Clone((nsIFile**)&file); + + if (NS_FAILED(rv)) return rv; + + rv = file->AppendRelativeNativePath(nsDependentCString(aLocation + 4)); + *aSpec = file; + return rv; + } + *aSpec = nsnull; return NS_ERROR_INVALID_ARG; } @@ -2598,13 +2661,6 @@ nsComponentManagerImpl::RegisterComponentSpec(const nsCID &aClass, return rv; } -/* - * Register a ``library'', which is a DLL location named by a simple filename - * such as ``libnsappshell.so'', rather than a relative or absolute path. - * - * It implies application/x-moz-dll as the component type, and skips the - * FindLoaderForType phase. - */ nsresult nsComponentManagerImpl::RegisterComponentLib(const nsCID &aClass, const char *aClassName, @@ -2613,12 +2669,8 @@ nsComponentManagerImpl::RegisterComponentLib(const nsCID &aClass, PRBool aReplace, PRBool aPersist) { - nsXPIDLCString registryName; - nsresult rv = RegistryNameForLib(aDllName, getter_Copies(registryName)); - if (NS_FAILED(rv)) - return rv; - return RegisterComponentCommon(aClass, aClassName, aContractID, registryName, - aReplace, aPersist, nativeComponentType); + // deprecated and obsolete. + return NS_ERROR_NOT_IMPLEMENTED; } /* @@ -3010,7 +3062,7 @@ nsComponentManagerImpl::AutoRegisterImpl(PRInt32 when, } else { - GetDefaultComponentsDirectory(getter_AddRefs(dir)); + GetLocationFromDirectoryService(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(dir)); if (!dir) return NS_ERROR_UNEXPECTED; } @@ -3088,7 +3140,7 @@ nsComponentManagerImpl::AutoRegisterNonNativeComponents(nsIFile* spec) nsCOMPtr directory = spec; if (!directory) { - GetDefaultComponentsDirectory(getter_AddRefs(directory)); + GetLocationFromDirectoryService(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(directory)); if (!directory) return NS_ERROR_UNEXPECTED; } @@ -3416,19 +3468,13 @@ nsComponentManagerImpl::HasFileChanged(nsIFile *file, const char *loaderString, if (NS_FAILED(rv)) return rv; - PRInt32 count = mAutoRegEntries.Count(); - for (PRInt32 i = 0; iModified(&modDate); + else + *_retval = PR_TRUE; - if (!strcmp(registryName.get(), entry->GetName())) - { - // Found in our array. - *_retval = entry->Modified(&modDate); - return NS_OK; - } - } return NS_OK; } @@ -3442,25 +3488,20 @@ nsComponentManagerImpl::SaveFileInfo(nsIFile *file, const char *loaderString, PR return rv; // check to see if exists in the array before adding it so that we don't have dups. - PRInt32 count = mAutoRegEntries.Count(); - for (PRInt32 i = 0; iGetName())) - { - entry->SetDate(&modDate); - return NS_OK; - } + if (entry) + { + entry->SetDate(&modDate); + return NS_OK; } - AutoRegEntry *entry = new AutoRegEntry(registryName, &modDate); - + entry = new AutoRegEntry(registryName, &modDate); if (!entry) return NS_ERROR_OUT_OF_MEMORY; - mAutoRegEntries.AppendElement(entry); + mAutoRegEntries.Put(&key, entry); return NS_OK; } @@ -3473,22 +3514,66 @@ nsComponentManagerImpl::RemoveFileInfo(nsIFile *file, const char *loaderString) if (NS_FAILED(rv)) return rv; - PRInt32 count = mAutoRegEntries.Count(); - for (PRInt32 i = 0; iGetName())) - { - mAutoRegEntries.RemoveElementAt(i); - delete entry; - return NS_OK; - } - } return NS_OK; } +NS_IMETHODIMP +nsComponentManagerImpl::GetOptionalData(nsIFile *file, + const char *loaderString, + char **_retval) +{ + nsXPIDLCString registryName; + nsresult rv = RegistryLocationForSpec(file, getter_Copies(registryName)); + if (NS_FAILED(rv)) + return rv; + + nsCStringKey key(registryName); + AutoRegEntry* entry = (AutoRegEntry*)mAutoRegEntries.Get(&key); + if (!entry) { + return NS_ERROR_NOT_INITIALIZED; + } + const char* opData = entry->GetOptionalData(); + + if (opData) + *_retval = ToNewCString(nsDependentCString(opData)); + else + *_retval = nsnull; + return NS_OK; + } + +NS_IMETHODIMP +nsComponentManagerImpl::SetOptionalData(nsIFile *file, + const char *loaderString, + const char *data) +{ + nsXPIDLCString registryName; + nsresult rv = RegistryLocationForSpec(file, getter_Copies(registryName)); + if (NS_FAILED(rv)) + return rv; + + nsCStringKey key(registryName); + AutoRegEntry* entry = (AutoRegEntry*)mAutoRegEntries.Get(&key); + + if (!entry) { + PRInt64 zero = LL_Zero(); + entry = new AutoRegEntry(registryName, &zero); + if (!entry) + return NS_ERROR_OUT_OF_MEMORY; + + mAutoRegEntries.Put(&key, entry); + } + + entry->SetOptionalData(data); + + return NS_OK; + } + + NS_IMETHODIMP nsComponentManagerImpl::FlushPersistentStore(PRBool now) { diff --git a/mozilla/xpcom/components/nsComponentManager.h b/mozilla/xpcom/components/nsComponentManager.h index 3862f4a6bc0..3c4be29da8e 100644 --- a/mozilla/xpcom/components/nsComponentManager.h +++ b/mozilla/xpcom/components/nsComponentManager.h @@ -73,8 +73,6 @@ class nsIServiceManager; // to service mapping and has no cid mapping. #define NS_COMPONENT_TYPE_SERVICE_ONLY -2 -extern const char XPCOM_LIB_PREFIX[]; - //////////////////////////////////////////////////////////////////////////////// // Array of Loaders and their type strings @@ -96,7 +94,6 @@ class nsComponentManagerImpl public: NS_DECL_ISUPPORTS NS_DECL_NSIINTERFACEREQUESTOR - // Since the nsIComponentManagerObsolete and nsIComponentManager share some of the // same interface function names, we have to manually define the functions here. // The only function that is in nsIComponentManagerObsolete and is in nsIComponentManager @@ -154,7 +151,6 @@ public: NS_GetService(const char *aContractID, const nsIID& aIID, PRBool aDontCreate, nsISupports** result); protected: - nsresult RegistryNameForLib(const char *aLibName, char **aRegistryName); nsresult RegisterComponentCommon(const nsCID &aClass, const char *aClassName, const char *aContractID, @@ -209,10 +205,15 @@ protected: PRMonitor* mMon; nsNativeComponentLoader *mNativeComponentLoader; +#ifdef ENABLE_STATIC_COMPONENT_LOADER nsIComponentLoader *mStaticComponentLoader; +#endif nsCOMPtr mComponentsDir; PRInt32 mComponentsOffset; + nsCOMPtr mGREComponentsDir; + PRInt32 mGREComponentsOffset; + // Shutdown #define NS_SHUTDOWN_NEVERHAPPENED 0 #define NS_SHUTDOWN_INPROGRESS 1 @@ -224,7 +225,7 @@ protected: int mMaxNLoaderData; PRBool mRegistryDirty; - nsVoidArray mAutoRegEntries; + nsHashtable mAutoRegEntries; nsCOMPtr mCategoryManager; PLArenaPool mArena; @@ -261,24 +262,6 @@ protected: #define NS_MOZILLA_DIR_PERMISSION 00700 #endif /* XP_BEOS */ -/** - * When using the registry we put a version number in it. - * If the version number that is in the registry doesn't match - * the following, we ignore the registry. This lets news versions - * of the software deal with old formats of registry and not - * - * alpha0.20 : First time we did versioning - * alpha0.30 : Changing autoreg to begin registration from ./components on unix - * alpha0.40 : repository -> component manager - * alpha0.50 : using nsIRegistry - * alpha0.60 : xpcom 2.0 landing - * alpha0.70 : using nsIFileSpec. PRTime -> PRUint32 - * alpha0.90 : using nsIComponentLoader, abs:/rel:/lib:, shaver-cleanup - * alpha0.92 : restructured registry keys - * alpha0.93 : changed component names to native strings instead of UTF8 - */ -#define NS_XPCOM_COMPONENT_MANAGER_VERSION_STRING "alpha0.93" - //////////////////////////////////////////////////////////////////////////////// /** * Class: nsFactoryEntry() @@ -347,7 +330,6 @@ struct nsContractIDTableEntry : public PLDHashEntryHdr { class AutoRegEntry { public: - AutoRegEntry(){}; AutoRegEntry(const char* name, PRInt64* modDate); virtual ~AutoRegEntry(); @@ -356,8 +338,14 @@ public: void SetDate(PRInt64 *date) { mModDate = *date;} PRBool Modified(PRInt64 *date); + // this is the optional field line in the compreg.dat. + // it must not contain any comma's and it must be null terminated. + char* GetOptionalData() {return mData;}; + void SetOptionalData(const char* data); + private: char* mName; + char* mData; PRInt64 mModDate; }; #endif // nsComponentManager_h__ diff --git a/mozilla/xpcom/components/nsIComponentLoaderManager.idl b/mozilla/xpcom/components/nsIComponentLoaderManager.idl index 577b1085ca5..9f1784d65a9 100644 --- a/mozilla/xpcom/components/nsIComponentLoaderManager.idl +++ b/mozilla/xpcom/components/nsIComponentLoaderManager.idl @@ -49,13 +49,16 @@ interface nsIFile; -[scriptable, uuid(fce83d37-a3c0-4e09-ad9f-6842a984dbdf)] +[uuid(fce83d37-a3c0-4e09-ad9f-6842a984dbdf)] interface nsIComponentLoaderManager : nsISupports { boolean hasFileChanged(in nsIFile file, in string loaderString, in PRInt64 modDate); void saveFileInfo(in nsIFile file, in string loaderString, in PRInt64 modDate); void removeFileInfo(in nsIFile file, in string loaderString); void flushPersistentStore(in boolean now); + + string getOptionalData(in nsIFile file, in string loaderString); + void setOptionalData(in nsIFile file, in string loaderString, in string value); }; diff --git a/mozilla/xpcom/components/nsINativeComponentLoader.idl b/mozilla/xpcom/components/nsINativeComponentLoader.idl new file mode 100644 index 00000000000..b2dc31ee1b4 --- /dev/null +++ b/mozilla/xpcom/components/nsINativeComponentLoader.idl @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * 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 NPL, 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 NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +interface nsIFile; + +[uuid(aa610f20-a889-11d3-8c81-000064657374)] +interface nsINativeComponentLoader : nsISupports +{ + + /** + * addDependentLibrary + * + * This method informs the native component loader that the + * given component library referenced by |aFile| requires + * symbols that can be found in the library named |aLibName|. + * + * The native component loader is expected to resolve these + * external symobls prior to loading the component library. + * + * @param aFile + * The native component file location that is declaring a + * a dependency. This file is expected to be a DSO/DLL. + * + * @param aLibName + * This is a name of a library that the component requires. + * This file name is found in either the GRE bin directory + * or the application's bin directory. Full file path are + * also accepted. Passing nsnull for the |aLibName| will + * clear all dependencies. Note that non null aLibName + * values are expected to be in the native charset. + */ + + void addDependentLibrary(in nsIFile aFile, in string aLibName); +}; diff --git a/mozilla/xpcom/components/nsNativeComponentLoader.cpp b/mozilla/xpcom/components/nsNativeComponentLoader.cpp index a41b60cca84..de52d4a33f3 100644 --- a/mozilla/xpcom/components/nsNativeComponentLoader.cpp +++ b/mozilla/xpcom/components/nsNativeComponentLoader.cpp @@ -76,7 +76,9 @@ nsNativeComponentLoader::~nsNativeComponentLoader() delete mDllStore; } -NS_IMPL_THREADSAFE_ISUPPORTS1(nsNativeComponentLoader, nsIComponentLoader); +NS_IMPL_THREADSAFE_ISUPPORTS2(nsNativeComponentLoader, + nsIComponentLoader, + nsINativeComponentLoader); NS_IMETHODIMP nsNativeComponentLoader::GetFactory(const nsIID & aCID, @@ -128,13 +130,7 @@ nsNativeComponentLoader::GetFactory(const nsIID & aCID, return rv; // XXX translate error code? rv = GetFactoryFromModule(dll, aCID, _retval); -#ifdef OBSOLETE_MODULE_LOADING - if (NS_FAILED(rv)) { - if (rv == NS_ERROR_FACTORY_NOT_LOADED) { - rv = GetFactoryFromNSGetFactory(dll, aCID, serviceMgr, _retval); - } - } -#endif + PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, ("nsNativeComponentLoader: Factory creation %s for %s", (NS_SUCCEEDED(rv) ? "succeeded" : "FAILED"), @@ -276,25 +272,6 @@ nsFreeLibrary(nsDll *dll, nsIServiceManager *serviceMgr, PRInt32 when) { rv = mobj->CanUnload(nsComponentManagerImpl::gComponentManager, &canUnload); } -#ifdef OBSOLETE_MODULE_LOADING - else - { - // Try the old method of module unloading - nsCanUnloadProc proc = (nsCanUnloadProc)dll->FindSymbol("NSCanUnload"); - if (proc) - { - canUnload = proc(serviceMgr); - rv = NS_OK; // No error status returned by call. - } - else - { - PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, - ("nsNativeComponentLoader: Unload cant get nsIModule or NSCanUnload for %s", - dll->GetDisplayPath())); - return rv; - } - } -#endif /* OBSOLETE_MODULE_LOADING */ mobj = nsnull; // Release our reference to the module object // When shutting down, whether we can unload the dll or not, @@ -420,21 +397,6 @@ nsNativeComponentLoader::SelfRegisterDll(nsDll *dll, } mobj = NULL; // Force a release of the Module object before unload() } -#ifdef OBSOLETE_MODULE_LOADING - else - { - res = NS_ERROR_NO_INTERFACE; - nsRegisterProc regproc = (nsRegisterProc)dll->FindSymbol("NSRegisterSelf"); - if (regproc) - { - // Call the NSRegisterSelfProc to enable dll registration - res = regproc(serviceMgr, registryLocation); - PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, - ("nsNativeComponentLoader: %s using OBSOLETE NSRegisterSelf()", - dll->GetDisplayPath())); - } - } -#endif /* OBSOLETE_MODULE_LOADING */ // Update the timestamp and size of the dll in registry // Don't enter deferred modules in the registry, because it might only be @@ -579,19 +541,6 @@ nsNativeComponentLoader::SelfUnregisterDll(nsDll *dll) if (NS_FAILED(res)) return res; mobj->UnregisterSelf(mCompMgr, fs, registryName); } -#ifdef OBSOLETE_MODULE_LOADING - else - { - res = NS_ERROR_NO_INTERFACE; - nsUnregisterProc unregproc = - (nsUnregisterProc) dll->FindSymbol("NSUnregisterSelf"); - if (unregproc) - { - // Call the NSUnregisterSelfProc to enable dll de-registration - res = unregproc(serviceMgr, dll->GetPersistentDescriptorString()); - } - } -#endif /* OBSOLETE_MODULE_LOADING */ return res; } @@ -863,7 +812,7 @@ nsNativeComponentLoader::AutoRegisterComponent(PRInt32 when, // It is ok to do this even if the creation of nsDll // didnt succeed. That way we wont do this again // when we encounter the same dll. - dll = new nsDll(persistentDescriptor); + dll = new nsDll(component, persistentDescriptor); if (dll == NULL) return NS_ERROR_OUT_OF_MEMORY; mDllStore->Put(&key, (void *) dll); @@ -999,19 +948,14 @@ nsNativeComponentLoader::CreateDll(nsIFile *aSpec, if (!aSpec) { - if (!nsCRT::strncmp(aLocation, XPCOM_LIB_PREFIX, 4)) { - dll = new nsDll(aLocation+4, 1 /* dumb magic flag */); - if (!dll) return NS_ERROR_OUT_OF_MEMORY; - } else { - // what I want to do here is QI for a Component Registration Manager. Since this - // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. - nsCOMPtr obsoleteManager = do_QueryInterface(mCompMgr, &rv); - if (obsoleteManager) - rv = obsoleteManager->SpecForRegistryLocation(aLocation, - getter_AddRefs(spec)); - if (NS_FAILED(rv)) - return rv; - } + // what I want to do here is QI for a Component Registration Manager. Since this + // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home. + nsCOMPtr obsoleteManager = do_QueryInterface(mCompMgr, &rv); + if (obsoleteManager) + rv = obsoleteManager->SpecForRegistryLocation(aLocation, + getter_AddRefs(spec)); + if (NS_FAILED(rv)) + return rv; } else { @@ -1046,11 +990,35 @@ nsNativeComponentLoader::GetFactoryFromModule(nsDll *aDll, const nsCID &aCID, (void **)aFactory); } -nsresult -nsNativeComponentLoader::GetFactoryFromNSGetFactory(nsDll *aDll, - const nsCID &aCID, - nsIServiceManager *aServMgr, - nsIFactory **aFactory) + +NS_IMETHODIMP +nsNativeComponentLoader::AddDependentLibrary(nsIFile* aFile, const char* libName) { - return NS_ERROR_FACTORY_NOT_LOADED; + nsCOMPtr manager = do_QueryInterface(mCompMgr); + if (!manager) + { + NS_WARNING("Something is terribly wrong"); + return NS_ERROR_FAILURE; + } + + // the native component loader uses the optional data + // to store a space delimited list of dependent library + // names + + if (!libName) + { + manager->SetOptionalData(aFile, nsnull, nsnull); + return NS_OK; + } + + nsXPIDLCString data; + manager->GetOptionalData(aFile, nsnull, getter_Copies(data)); + + if (!data.IsEmpty()) + data.Append(NS_LITERAL_CSTRING(" ")); + + data.Append(nsDependentCString(libName)); + + manager->SetOptionalData(aFile, nsnull, data); + return NS_OK; } diff --git a/mozilla/xpcom/components/nsNativeComponentLoader.h b/mozilla/xpcom/components/nsNativeComponentLoader.h index 1d06cc1cf6d..c6af90a0f3d 100644 --- a/mozilla/xpcom/components/nsNativeComponentLoader.h +++ b/mozilla/xpcom/components/nsNativeComponentLoader.h @@ -25,15 +25,17 @@ #include "nsHashtable.h" #include "nsVoidArray.h" #include "xcDll.h" +#include "nsINativeComponentLoader.h" #ifndef nsNativeComponentLoader_h__ #define nsNativeComponentLoader_h__ -class nsNativeComponentLoader : public nsIComponentLoader { +class nsNativeComponentLoader : public nsIComponentLoader, public nsINativeComponentLoader { public: NS_DECL_ISUPPORTS NS_DECL_NSICOMPONENTLOADER + NS_DECL_NSINATIVECOMPONENTLOADER nsNativeComponentLoader(); virtual ~nsNativeComponentLoader(); @@ -51,11 +53,6 @@ class nsNativeComponentLoader : public nsIComponentLoader { nsresult SelfUnregisterDll(nsDll *dll); nsresult GetFactoryFromModule(nsDll *aDll, const nsCID &aCID, nsIFactory **aFactory); - /* obsolete! already! */ - nsresult GetFactoryFromNSGetFactory(nsDll *aDlll, const nsCID &aCID, - nsIServiceManager *aServMgr, - nsIFactory **aFactory); - nsresult DumpLoadError(nsDll *dll, const char *aCallerName, diff --git a/mozilla/xpcom/components/xcDll.cpp b/mozilla/xpcom/components/xcDll.cpp index 226242b007a..4e8828d37af 100644 --- a/mozilla/xpcom/components/xcDll.cpp +++ b/mozilla/xpcom/components/xcDll.cpp @@ -49,6 +49,8 @@ #include "nsIComponentLoaderManager.h" #include "nsIModule.h" #include "nsILocalFile.h" +#include "nsDirectoryServiceDefs.h" +#include "nsDirectoryServiceUtils.h" #include "nsCOMPtr.h" #include "nsCRT.h" #include "nsString.h" @@ -64,92 +66,22 @@ #include "nsNativeComponentLoader.h" -nsDll::nsDll(const char *codeDllName, int type) - : m_dllName(NULL), - m_instance(NULL), m_status(DLL_OK), m_moduleObject(NULL), - m_persistentDescriptor(NULL), m_nativePath(NULL), - m_markForUnload(PR_FALSE), m_registryLocation(0) +extern nsresult NS_GetComponentLoaderManager(nsIComponentLoaderManager* *result); +nsDll::nsDll(nsIFile *dllSpec, + const char *registryLocation) + : + m_dllSpec(do_QueryInterface(dllSpec)), + m_instance(NULL), + m_status(DLL_OK), + m_moduleObject(NULL), + m_markForUnload(PR_FALSE) { - if (!codeDllName || !*codeDllName) - { - m_status = DLL_INVALID_PARAM; - return; - } - m_dllName = nsCRT::strdup(codeDllName); - if (!m_dllName) - { - m_status = DLL_NO_MEM; - return; - } -} - -nsDll::nsDll(nsIFile *dllSpec, const char *registryLocation) - : m_dllName(NULL), - m_instance(NULL), m_status(DLL_OK), m_moduleObject(NULL), - m_persistentDescriptor(NULL), m_nativePath(NULL), m_markForUnload(PR_FALSE) - -{ - m_dllSpec = dllSpec; + NS_ASSERTION(registryLocation, "registryLocation is null"); m_registryLocation = nsCRT::strdup(registryLocation); - Init(dllSpec); } -nsDll::nsDll(const char *libPersistentDescriptor) - : m_dllName(NULL), - m_instance(NULL), m_status(DLL_OK), m_moduleObject(NULL), - m_persistentDescriptor(NULL), m_nativePath(NULL), - m_markForUnload(PR_FALSE), m_registryLocation(0) - -{ - Init(libPersistentDescriptor); -} - -void -nsDll::Init(nsIFile *dllSpec) -{ - // Load will fail anyway. So dont bother to stat the file - - m_dllSpec = do_QueryInterface(dllSpec); - m_status = DLL_OK; -} - -void -nsDll::Init(const char *libPersistentDescriptor) -{ - nsresult rv; - - if (libPersistentDescriptor == NULL) - { - m_status = DLL_INVALID_PARAM; - return; - } - - // Create a FileSpec from the persistentDescriptor - nsCOMPtr dllSpec; - - nsCID clsid; - nsComponentManager::ContractIDToClassID(NS_LOCAL_FILE_CONTRACTID, &clsid); - rv = nsComponentManager::CreateInstance(clsid, nsnull, - NS_GET_IID(nsILocalFile), - (void**)getter_AddRefs(dllSpec)); - if (NS_FAILED(rv)) - { - m_status = DLL_INVALID_PARAM; - return; - } - - rv = dllSpec->InitWithNativePath(nsDependentCString(libPersistentDescriptor)); - if (NS_FAILED(rv)) - { - m_status = DLL_INVALID_PARAM; - return; - } - -} - - nsDll::~nsDll(void) { #if DEBUG_dougt @@ -161,43 +93,21 @@ nsDll::~nsDll(void) // Hence turn it back on after all the above have been removed. Unload(); #endif - if (m_dllName) - nsCRT::free(m_dllName); if (m_registryLocation) nsCRT::free(m_registryLocation); - } - const char * nsDll::GetDisplayPath() { - if (m_dllName) - return m_dllName; - if (!m_nativePath.IsEmpty()) - return m_nativePath.get(); - m_dllSpec->GetNativePath(m_nativePath); - return m_nativePath.get(); -} - -const char * -nsDll::GetPersistentDescriptorString() -{ - if (m_dllName) - return m_dllName; - if (!m_persistentDescriptor.IsEmpty()) - return m_persistentDescriptor.get(); - m_dllSpec->GetNativePath(m_persistentDescriptor); - return m_persistentDescriptor.get(); + if (m_registryLocation) + return m_registryLocation; + return "unknown!"; } PRBool nsDll::HasChanged() { - if (m_dllName) - return PR_FALSE; - - extern nsresult NS_GetComponentLoaderManager(nsIComponentLoaderManager* *result); nsCOMPtr manager; NS_GetComponentLoaderManager(getter_AddRefs(manager)); if (!manager) @@ -206,6 +116,8 @@ nsDll::HasChanged() // If mod date has changed, then dll has changed PRInt64 currentDate; nsresult rv = m_dllSpec->GetLastModifiedTime(¤tDate); + if (NS_FAILED(rv)) + return PR_TRUE; PRBool changed = PR_TRUE; manager->HasFileChanged(m_dllSpec, nsnull, currentDate, &changed); return changed; @@ -228,10 +140,107 @@ PRBool nsDll::Load(void) #ifdef NS_BUILD_REFCNT_LOGGING nsTraceRefcnt::SetActivityIsLegal(PR_FALSE); #endif - nsCOMPtr lf(do_QueryInterface(m_dllSpec)); - NS_ASSERTION(lf, "nsIFile here must implement a nsILocalFile"); - lf->Load(&m_instance); + // Load any library dependencies + // The Component Loader Manager may hold onto some extra data + // set by either the native component loader or the native + // component. We assume that this data is a space delimited + // listing of dependent libraries which are required to be + // loaded prior to us loading the given component. Once, the + // component is loaded into memory, we can release our hold + // on the dependent libraries with the assumption that the + // component library holds a reference via the OS so loader. + + nsCOMPtr manager; + NS_GetComponentLoaderManager(getter_AddRefs(manager)); + if (!manager) + return PR_TRUE; + + nsXPIDLCString extraData; + manager->GetOptionalData(m_dllSpec, m_registryLocation, getter_Copies(extraData)); + + nsVoidArray dependentLibArray; + + // if there was any extra data, treat it as a listing of dependent libs + if (extraData != nsnull) + { + + // all dependent libraries are suppose to be in the "gre" directory. + // note that the gre directory is the same as the "bin" directory, + // when there isn't a real "gre" found. + + nsXPIDLCString path; + nsCOMPtr file; + NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(file)); + + if (!file) + return NS_ERROR_FAILURE; + + // we are talking about a file in the GRE dir. Lets append something + // stupid right now, so that later we can just set the leaf name. + file->AppendNative(NS_LITERAL_CSTRING("dummy")); + + char *buffer = strdup(extraData); + if (!buffer) + return NS_ERROR_OUT_OF_MEMORY; + + char* newStr; + char *token = nsCRT::strtok(buffer, " ", &newStr); + while (token!=nsnull) + { + nsXPIDLCString libpath; + file->SetNativeLeafName(nsDependentCString(token)); + file->GetNativePath(path); + if (!path) + return NS_ERROR_FAILURE; + + // Load this dependent library with the global flag and stash + // the result for later so that we can unload it. + PRLibSpec libSpec; + libSpec.type = PR_LibSpec_Pathname; + + // if the depend library path starts with a / we are + // going to assume that it is a full path and should + // be loaded without prepending the gre diretory + // location. We could have short circuited the + // SetNativeLeafName above, but this is clearer and + // the common case is a relative path. + + if (token[0] == '/') + libSpec.value.pathname = token; + else + libSpec.value.pathname = path; + + PRLibrary* lib = PR_LoadLibraryWithFlags(libSpec, PR_LD_LAZY|PR_LD_GLOBAL); + // if we couldn't load the dependent library. We did the best we + // can. Now just let us fail later if this really was a required + // dependency. + if (lib) + dependentLibArray.AppendElement((void*)lib); + + token = nsCRT::strtok(newStr, " ", &newStr); + } + free(buffer); + } + + // load the component + + nsCOMPtr lf(do_QueryInterface(m_dllSpec)); + NS_ASSERTION(lf, "nsIFile here must implement a nsILocalFile"); + lf->Load(&m_instance); + + + // Unload any of library dependencies we loaded earlier. The assumption + // here is that the component will have a "internal" reference count to + // the dependency library we just loaded. + // XXX should we unload later - or even at all? + + if (extraData != nsnull) + { + PRInt32 arrayCount = dependentLibArray.Count(); + for (PRInt32 index = 0; index < arrayCount; index++) + PR_UnloadLibrary((PRLibrary*)dependentLibArray.ElementAt(index)); + } #ifdef NS_BUILD_REFCNT_LOGGING nsTraceRefcnt::SetActivityIsLegal(PR_TRUE); if (m_instance) { @@ -243,28 +252,8 @@ PRBool nsDll::Load(void) } #endif } - else if (m_dllName) - { - // if there is not an nsIFile, but there is a dll name, just try to load that.. -#ifdef NS_BUILD_REFCNT_LOGGING - nsTraceRefcnt::SetActivityIsLegal(PR_FALSE); -#endif - NS_TIMELINE_START_TIMER("PR_LoadLibrary"); - m_instance = PR_LoadLibrary(m_dllName); - NS_TIMELINE_STOP_TIMER("PR_LoadLibrary"); - NS_TIMELINE_MARK_TIMER("PR_LoadLibrary"); -#ifdef NS_BUILD_REFCNT_LOGGING - nsTraceRefcnt::SetActivityIsLegal(PR_TRUE); - if (m_instance) { - // Inform refcnt tracer of new library so that calls through the - // new library can be traced. - nsTraceRefcnt::LoadLibrarySymbols(m_dllName, m_instance); - } -#endif - } - -#if defined(DEBUG) && defined(XP_UNIX) +#ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD // Debugging help for components. Component dlls need to have their // symbols loaded before we can put a breakpoint in the debugger. // This will help figureing out the point when the dll was loaded. @@ -342,11 +331,10 @@ nsresult nsDll::GetModule(nsISupports *servMgr, nsIModule **cobj) // If not already loaded, load it now. if (Load() != PR_TRUE) return NS_ERROR_FAILURE; - // We need a nsIFile for location. If we dont - // have one, create one. - if (!m_dllSpec && m_dllName) + // We need a nsIFile for location + if (!m_dllSpec) { - // Create m_dllSpec from m_dllName + return NS_ERROR_FAILURE; } nsGetModuleProc proc = @@ -364,9 +352,6 @@ nsresult nsDll::GetModule(nsISupports *servMgr, nsIModule **cobj) return rv; } -#if defined(DEBUG) && !defined(XP_BEOS) -#define SHOULD_IMPLEMENT_BREAKAFTERLOAD -#endif // These are used by BreakAfterLoad, below. #ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD @@ -394,10 +379,9 @@ nsresult nsDll::Shutdown(void) return NS_OK; } - +#ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD void nsDll::BreakAfterLoad(const char *nsprPath) { -#ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD static PRBool firstTime = PR_TRUE; // return if invalid input @@ -444,6 +428,6 @@ void nsDll::BreakAfterLoad(const char *nsprPath) raise(SIGTRAP); #endif } -#endif /* SHOULD_IMPLEMENT_BREAKAFTERLOAD */ return; } +#endif /* SHOULD_IMPLEMENT_BREAKAFTERLOAD */ diff --git a/mozilla/xpcom/components/xcDll.h b/mozilla/xpcom/components/xcDll.h index 415aaa1fc22..8287b14cbe8 100644 --- a/mozilla/xpcom/components/xcDll.h +++ b/mozilla/xpcom/components/xcDll.h @@ -53,6 +53,10 @@ #include "nsCOMPtr.h" #include "nsString.h" +#if defined(DEBUG) && !defined(XP_BEOS) +#define SHOULD_IMPLEMENT_BREAKAFTERLOAD +#endif + class nsIModule; class nsIServiceManager; @@ -68,32 +72,25 @@ typedef enum nsDllStatus class nsDll { private: - char *m_dllName; // Stores the dllName to load. - - nsCOMPtr m_dllSpec; // Filespec representing the component - - PRLibrary *m_instance; // Load instance - nsDllStatus m_status; // holds current status - nsIModule *m_moduleObject; - - // Cache frequent queries - nsCString m_persistentDescriptor; - nsCString m_nativePath; - - PRBool m_markForUnload; + nsCOMPtr m_dllSpec; char *m_registryLocation; + + PRLibrary *m_instance; // Load instance + nsDllStatus m_status; // holds current status + nsIModule *m_moduleObject; + + PRBool m_markForUnload; + void Init(nsIFile *dllSpec); - void Init(const char *persistentDescriptor); +#ifdef SHOULD_IMPLEMENT_BREAKAFTERLOAD void BreakAfterLoad(const char *nsprPath); +#endif public: nsDll(nsIFile *dllSpec, const char *registryLocation); - nsDll(const char *persistentDescriptor); - nsDll(const char *dll, int type /* dummy */); - ~nsDll(void); // Status checking on operations completed @@ -119,10 +116,10 @@ public: // WARNING: DONT FREE string returned. const char *GetDisplayPath(void); - // WARNING: DONT FREE string returned. - const char *GetPersistentDescriptorString(void); + // WARNING: DONT FREE string returned. const char *GetRegistryLocation(void) { return m_registryLocation; } + PRLibrary *GetInstance(void) { return (m_instance); } // NS_RELEASE() is required to be done on objects returned diff --git a/mozilla/xpcom/glue/nsGenericFactory.cpp b/mozilla/xpcom/glue/nsGenericFactory.cpp index 271c43284ca..54121cffde8 100644 --- a/mozilla/xpcom/glue/nsGenericFactory.cpp +++ b/mozilla/xpcom/glue/nsGenericFactory.cpp @@ -52,6 +52,9 @@ #include "nsDirectoryServiceDefs.h" #include "nsDirectoryService.h" #include "nsEmbedString.h" +#else +#include "nsIInterfaceRequestorUtils.h" +#include "nsINativeComponentLoader.h" #endif nsGenericFactory::nsGenericFactory(const nsModuleComponentInfo *info) @@ -224,14 +227,16 @@ NS_NewGenericFactory(nsIGenericFactory* *result, nsGenericModule::nsGenericModule(const char* moduleName, PRUint32 componentCount, const nsModuleComponentInfo* components, nsModuleConstructorProc ctor, - nsModuleDestructorProc dtor) + nsModuleDestructorProc dtor, + const char** aLibDepends) : mInitialized(PR_FALSE), mModuleName(moduleName), mComponentCount(componentCount), mComponents(components), mFactoriesNotToBeRegistered(nsnull), mCtor(ctor), - mDtor(dtor) + mDtor(dtor), + mLibraryDependencies(aLibDepends) { } @@ -460,6 +465,25 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr, cp++; } +#ifndef XPCOM_GLUE + // We want to tell the component loader of any dependencies + // we have so that the loader can resolve them for us. + + nsCOMPtr loader = do_GetInterface(aCompMgr); + if (loader && mLibraryDependencies) + { + for(int i=0; mLibraryDependencies[i] != nsnull && + mLibraryDependencies[i][0] != '\0'; i++) + { + loader->AddDependentLibrary(aPath, + mLibraryDependencies[i]); + } + loader = nsnull; + } +#endif + + + return rv; } @@ -514,7 +538,7 @@ NS_NewGenericModule2(nsModuleInfo* info, nsIModule* *result) // Create and initialize the module instance nsGenericModule *m = new nsGenericModule(info->mModuleName, info->mCount, info->mComponents, - info->mCtor, info->mDtor); + info->mCtor, info->mDtor, info->mLibraryDependencies); if (!m) return NS_ERROR_OUT_OF_MEMORY; @@ -543,6 +567,7 @@ NS_NewGenericModule(const char* moduleName, info.mComponents = components; info.mCount = componentCount; info.mDtor = dtor; + info.mLibraryDependencies = nsnull; return NS_NewGenericModule2(&info, result); } diff --git a/mozilla/xpcom/glue/nsGenericFactory.h b/mozilla/xpcom/glue/nsGenericFactory.h index b6f556cf655..d0c335cb9c4 100644 --- a/mozilla/xpcom/glue/nsGenericFactory.h +++ b/mozilla/xpcom/glue/nsGenericFactory.h @@ -81,7 +81,8 @@ public: PRUint32 componentCount, const nsModuleComponentInfo* components, nsModuleConstructorProc ctor, - nsModuleDestructorProc dtor); + nsModuleDestructorProc dtor, + const char** alibDepends); virtual ~nsGenericModule(); @@ -118,6 +119,7 @@ protected: FactoryNode* mFactoriesNotToBeRegistered; nsModuleConstructorProc mCtor; nsModuleDestructorProc mDtor; + const char** mLibraryDependencies; }; #endif /* nsGenericFactory_h___ */ diff --git a/mozilla/xpcom/glue/nsIGenericFactory.h b/mozilla/xpcom/glue/nsIGenericFactory.h index e6fe3404586..0d3a8750b6f 100644 --- a/mozilla/xpcom/glue/nsIGenericFactory.h +++ b/mozilla/xpcom/glue/nsIGenericFactory.h @@ -277,6 +277,8 @@ typedef void (PR_CALLBACK *nsModuleDestructorProc) (nsIModule *self); * @param mCount : Count of mComponents * @param mCtor : Module user defined constructor * @param mDtor : Module user defined destructor + * @param mLibraryDependencies : array of library which this module is + * dependent on. * **/ @@ -287,6 +289,7 @@ struct nsModuleInfo { PRUint32 mCount; nsModuleConstructorProc mCtor; nsModuleDestructorProc mDtor; + const char** mLibraryDependencies; }; /** @@ -294,7 +297,7 @@ struct nsModuleInfo { * binary compatibility. (Ostensibly fix NS_NewGenericModule2() to deal * with older rev's at the same time.) */ -#define NS_MODULEINFO_VERSION 0x00010000UL // 1.0 +#define NS_MODULEINFO_VERSION 0x00015000UL // 1.5 /** * Create a new generic module. Use the NS_IMPL_NSGETMODULE macro, or @@ -350,7 +353,8 @@ nsModuleInfo NSMODULEINFO(_name) = { \ (_components), \ (sizeof(_components) / sizeof(_components[0])), \ (_ctor), \ - (_dtor) \ + (_dtor), \ + (nsnull) \ }; \ NSGETMODULE_ENTRY_POINT(NSMODULEINFO(_name)) diff --git a/mozilla/xpcom/reflect/xptinfo/src/xptiManifest.cpp b/mozilla/xpcom/reflect/xptinfo/src/xptiManifest.cpp index f2a9e80e3f2..1cb6a5d64f4 100644 --- a/mozilla/xpcom/reflect/xptinfo/src/xptiManifest.cpp +++ b/mozilla/xpcom/reflect/xptinfo/src/xptiManifest.cpp @@ -131,6 +131,7 @@ PRBool xptiManifest::Write(xptiInterfaceInfoManager* aMgr, PRUint32 size32; PRIntn interfaceCount = 0; nsCAutoString appDirString; + nsCOMPtr greDirectory; nsCOMPtr tempFile; if(!aMgr->GetCloneOfManifestDir(getter_AddRefs(tempFile)) || !tempFile) @@ -177,6 +178,8 @@ PRBool xptiManifest::Write(xptiInterfaceInfoManager* aMgr, (int) aWorkingSet->GetDirectoryCount())) goto out; + NS_GetSpecialDirectory(NS_GRE_COMPONENT_DIR, getter_AddRefs(greDirectory)); + for(i = 0; i < aWorkingSet->GetDirectoryCount(); i++) { nsCOMPtr dir; @@ -186,9 +189,19 @@ PRBool xptiManifest::Write(xptiInterfaceInfoManager* aMgr, if(!dir) goto out; - dir->GetPersistentDescriptor(str); - if(str.IsEmpty()) - goto out; + PRBool isGREDir = PR_FALSE; + if (greDirectory) + dir->Equals(greDirectory, &isGREDir); + + if (isGREDir) { + str = "gre"; + } + else + { + dir->GetPersistentDescriptor(str); + if(str.IsEmpty()) + goto out; + } if(!PR_fprintf(fd, "%d,%s\n", (int) i, str.get())) goto out; @@ -491,6 +504,8 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr, for(i = 0; i < dirCount; ++i) { + nsCAutoString str; + if(!reader.NextLine()) goto out; @@ -502,8 +517,23 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr, if(i != atoi(values[0])) goto out; + if (strcmp(values[1], "gre")) + { + nsCOMPtr greDirectory; + NS_GetSpecialDirectory(NS_GRE_COMPONENT_DIR, getter_AddRefs(greDirectory)); + nsCOMPtr lFile = do_QueryInterface(greDirectory); + if (!lFile) + goto out; + + lFile->GetPersistentDescriptor(str); + } + else + { + str = values[1]; + } + // directoryname - if(!aWorkingSet->DirectoryAtMatchesPersistentDescriptor(i, values[1])) + if(!aWorkingSet->DirectoryAtMatchesPersistentDescriptor(i, str.get())) goto out; } diff --git a/mozilla/xpfe/bootstrap/Makefile.in b/mozilla/xpfe/bootstrap/Makefile.in index e70fc6feb80..823d71630aa 100644 --- a/mozilla/xpfe/bootstrap/Makefile.in +++ b/mozilla/xpfe/bootstrap/Makefile.in @@ -116,9 +116,7 @@ STACKWALK_CPPSRCS := $(addprefix $(topsrcdir)/xpcom/base/, $(STACKWALK_SRC_LCSRC CPPSRCS += nsSigHandlers.cpp nsStackFrameUnix.cpp endif -LIBS = $(EXTRA_DSO_LDOPTS) \ - $(EXTRA_DSO_LIBS) \ - $(NULL) +LIBS = $(NULL) ifndef BUILD_STATIC_LIBS @@ -157,7 +155,6 @@ LIBS += $(XPCOM_LIBS) endif LIBS += \ - $(MOZ_JS_LIBS) \ $(NSPR_LIBS) \ $(NULL)