Backout of 193442/191415. a=brade,dougt

This commit is contained in:
tor%cs.brown.edu 2003-03-03 21:00:07 +00:00
parent 9024b2c79f
commit db50a85d91
15 changed files with 385 additions and 554 deletions

View File

@ -524,18 +524,6 @@ 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)))
_BEFORE := , \"
_AFTER := ,\"
_DEP_DEFINES = -DDEPENDENT_LIBS="$(foreach f,$(DEPENDENT_LIBS),\"${f}\",)"
_DEP_DEFINES := $(subst $(_BEFORE),$(_AFTER),$(_DEP_DEFINES))
DEFINES += $(_DEP_DEFINES)
endif
endif
################################################################################
all::
@ -1681,7 +1669,6 @@ 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)

View File

@ -148,6 +148,7 @@ 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);

View File

@ -70,17 +70,16 @@ 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))

View File

@ -61,8 +61,6 @@
#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...
@ -121,7 +119,7 @@ const char versionValueName[]="VersionString";
const static char XPCOM_ABSCOMPONENT_PREFIX[] = "abs:";
const static char XPCOM_RELCOMPONENT_PREFIX[] = "rel:";
const static char XPCOM_GRECOMPONENT_PREFIX[] = "gre:";
const char XPCOM_LIB_PREFIX[] = "lib:";
const static char persistentRegistryFilename[] = "compreg.dat";
const static char persistentRegistryTempFilename[] = "compreg.tmp";
@ -672,8 +670,7 @@ ConvertContractIDKeyToString(PLDHashTable *table,
}
// this is safe to call during InitXPCOM
static nsresult GetLocationFromDirectoryService(const char* prop,
nsIFile** aDirectory)
static nsresult GetDefaultComponentsDirectory(nsIFile** aDirectory)
{
nsCOMPtr<nsIProperties> directoryService;
nsDirectoryService::Create(nsnull,
@ -683,12 +680,11 @@ static nsresult GetLocationFromDirectoryService(const char* prop,
if (!directoryService)
return NS_ERROR_FAILURE;
return directoryService->Get(prop,
return directoryService->Get(NS_XPCOM_COMPONENT_DIR,
NS_GET_IID(nsIFile),
(void**)aDirectory);
}
////////////////////////////////////////////////////////////////////////////////
// nsComponentManagerImpl
////////////////////////////////////////////////////////////////////////////////
@ -698,9 +694,7 @@ nsComponentManagerImpl::nsComponentManagerImpl()
:
mMon(NULL),
mNativeComponentLoader(0),
#ifdef ENABLE_STATIC_COMPONENT_LOADER
mStaticComponentLoader(0),
#endif
mShuttingDown(NS_SHUTDOWN_NEVERHAPPENED),
mLoaderData(nsnull),
mRegistryDirty(PR_FALSE)
@ -720,6 +714,8 @@ 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
@ -802,9 +798,8 @@ nsresult nsComponentManagerImpl::Init(void)
mStaticComponentLoader->Init(this, nsnull);
}
#endif
NR_StartupRegistry();
GetLocationFromDirectoryService(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(mComponentsDir));
GetDefaultComponentsDirectory(getter_AddRefs(mComponentsDir));
if (!mComponentsDir)
return NS_ERROR_OUT_OF_MEMORY;
@ -815,28 +810,13 @@ nsresult nsComponentManagerImpl::Init(void)
mComponentsOffset = componentDescriptor.Length();
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();
}
NR_StartupRegistry();
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);
@ -860,8 +840,11 @@ nsresult nsComponentManagerImpl::Shutdown(void)
#endif
}
}
mAutoRegEntries.Reset(AutoRegEntryDestroy);
for (i = mAutoRegEntries.Count() - 1; i >= 0; i--) {
AutoRegEntry* entry = NS_STATIC_CAST(AutoRegEntry*, mAutoRegEntries[i]);
delete entry;
mAutoRegEntries.RemoveElementAt(i);
}
// Release all cached factories
if (mContractIDs.ops) {
@ -934,16 +917,14 @@ NS_IMPL_THREADSAFE_ISUPPORTS8(nsComponentManagerImpl,
nsresult
nsComponentManagerImpl::GetInterface(const nsIID & uuid, void **result)
{
if (uuid.Equals(NS_GET_IID(nsINativeComponentLoader)))
if (uuid.Equals(NS_GET_IID(nsIServiceManager)))
{
if (!mNativeComponentLoader)
return NS_ERROR_NOT_INITIALIZED;
return mNativeComponentLoader->QueryInterface(uuid, result);
*result = NS_STATIC_CAST(nsIServiceManager*, this);
NS_ADDREF_THIS();
return NS_OK;
}
NS_WARNING("This isn't supported");
// fall through to QI as anything QIable is a superset of what can be
// fall through to QI as anything QIable is a superset of what canbe
// got via the GetInterface()
return QueryInterface(uuid, result);
}
@ -960,12 +941,10 @@ 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
@ -974,19 +953,6 @@ 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)
@ -1118,9 +1084,8 @@ nsComponentManagerImpl::ReadPersistentRegistry()
if (!reader.NextLine())
break;
//name,last_modification_date[,optionaldata]
int parts = reader.ParseLine(values, lengths, 3);
if (2 > parts)
//name,last_modification_date
if (2 != reader.ParseLine(values, lengths, 2))
break;
PRInt64 a = nsCRT::atoll(values[1]);
@ -1129,11 +1094,7 @@ nsComponentManagerImpl::ReadPersistentRegistry()
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
if (parts == 3)
entry->SetOptionalData(values[2]);
nsCStringKey key((const char*)values[0]);
mAutoRegEntries.Put(&key, entry);
mAutoRegEntries.AppendElement(entry);
}
if (ReadSectionHeader(reader, "CLASSIDS"))
@ -1321,20 +1282,18 @@ ClassIDWriter(PLDHashTable *table,
return PL_DHASH_NEXT;
}
PRIntn PR_CALLBACK
AutoRegEntryWriter(nsHashKey *aKey, void *aData, void* aClosure)
PR_STATIC_CALLBACK(PRBool)
AutoRegEntryWriter(void* aElement, void *aData)
{
PRFileDesc* fd = (PRFileDesc*) aClosure;
AutoRegEntry* entry = (AutoRegEntry*) aData;
PRFileDesc* fd = (PRFileDesc*) aData;
AutoRegEntry* entry = (AutoRegEntry*) aElement;
//name,last_modification_date
PR_fprintf(fd,
"%s,%lld\n",
entry->GetName(),
entry->GetDate());
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;
}
@ -1441,7 +1400,7 @@ nsComponentManagerImpl::WritePersistentRegistry()
if (!PR_fprintf(fd, "\n[COMPONENTS]\n"))
goto out;
mAutoRegEntries.Enumerate(AutoRegEntryWriter, (void*)fd);
mAutoRegEntries.EnumerateForwards(AutoRegEntryWriter, (void*)fd);
PersistentWriterArgs args;
args.mFD = fd;
@ -1867,7 +1826,6 @@ nsComponentManagerImpl::CreateInstance(const nsCID &aClass,
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
}
if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_ALWAYS))
{
char *buf = aClass.ToString();
@ -1892,9 +1850,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
@ -2415,6 +2373,13 @@ 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)
@ -2429,42 +2394,30 @@ 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 nativePathString;
nsCAutoString persistentDescriptor;
if (containedIn){
rv = aSpec->GetNativePath(nativePathString);
rv = aSpec->GetNativePath(persistentDescriptor);
if (NS_FAILED(rv))
return rv;
const char* relativeLocation = nativePathString.get() + mComponentsOffset + 1;
return MakeRegistryName(relativeLocation, XPCOM_RELCOMPONENT_PREFIX, aRegistryName);
}
const char* relativeLocation = persistentDescriptor.get() + mComponentsOffset + 1;
// 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);
rv = MakeRegistryName(relativeLocation, XPCOM_RELCOMPONENT_PREFIX,
aRegistryName);
} else {
/* absolute names include volume info on Mac, so persistent descriptor */
rv = aSpec->GetNativePath(persistentDescriptor);
if (NS_FAILED(rv))
return rv;
const char* relativeLocation = nativePathString.get() + mGREComponentsOffset + 1;
return MakeRegistryName(relativeLocation, XPCOM_GRECOMPONENT_PREFIX, aRegistryName);
}
rv = MakeRegistryName(persistentDescriptor.get(), XPCOM_ABSCOMPONENT_PREFIX,
aRegistryName);
}
/* 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);
return rv;
}
nsresult
@ -2502,22 +2455,6 @@ 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;
}
@ -2661,6 +2598,13 @@ 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,
@ -2669,8 +2613,12 @@ nsComponentManagerImpl::RegisterComponentLib(const nsCID &aClass,
PRBool aReplace,
PRBool aPersist)
{
// deprecated and obsolete.
return NS_ERROR_NOT_IMPLEMENTED;
nsXPIDLCString registryName;
nsresult rv = RegistryNameForLib(aDllName, getter_Copies(registryName));
if (NS_FAILED(rv))
return rv;
return RegisterComponentCommon(aClass, aClassName, aContractID, registryName,
aReplace, aPersist, nativeComponentType);
}
/*
@ -3062,7 +3010,7 @@ nsComponentManagerImpl::AutoRegisterImpl(PRInt32 when,
}
else
{
GetLocationFromDirectoryService(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(dir));
GetDefaultComponentsDirectory(getter_AddRefs(dir));
if (!dir)
return NS_ERROR_UNEXPECTED;
}
@ -3140,7 +3088,7 @@ nsComponentManagerImpl::AutoRegisterNonNativeComponents(nsIFile* spec)
nsCOMPtr<nsIFile> directory = spec;
if (!directory) {
GetLocationFromDirectoryService(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(directory));
GetDefaultComponentsDirectory(getter_AddRefs(directory));
if (!directory)
return NS_ERROR_UNEXPECTED;
}
@ -3468,13 +3416,19 @@ nsComponentManagerImpl::HasFileChanged(nsIFile *file, const char *loaderString,
if (NS_FAILED(rv))
return rv;
nsCStringKey key(registryName);
AutoRegEntry* entry = (AutoRegEntry*)mAutoRegEntries.Get(&key);
if (entry)
*_retval = entry->Modified(&modDate);
else
*_retval = PR_TRUE;
PRInt32 count = mAutoRegEntries.Count();
for (PRInt32 i = 0; i<count; i++)
{
AutoRegEntry* entry = (AutoRegEntry*) mAutoRegEntries.ElementAt(i);
NS_ASSERTION(entry, "bad entry in array");
if (!strcmp(registryName.get(), entry->GetName()))
{
// Found in our array.
*_retval = entry->Modified(&modDate);
return NS_OK;
}
}
return NS_OK;
}
@ -3488,20 +3442,25 @@ 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.
nsCStringKey key(registryName);
AutoRegEntry* entry = (AutoRegEntry*)mAutoRegEntries.Get(&key);
if (entry)
PRInt32 count = mAutoRegEntries.Count();
for (PRInt32 i = 0; i<count; i++)
{
entry->SetDate(&modDate);
return NS_OK;
AutoRegEntry* entry = (AutoRegEntry*) mAutoRegEntries.ElementAt(i);
NS_ASSERTION(entry, "bad entry in array");
if (!strcmp(registryName.get(), entry->GetName()))
{
entry->SetDate(&modDate);
return NS_OK;
}
}
entry = new AutoRegEntry(registryName, &modDate);
AutoRegEntry *entry = new AutoRegEntry(registryName, &modDate);
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
mAutoRegEntries.Put(&key, entry);
mAutoRegEntries.AppendElement(entry);
return NS_OK;
}
@ -3514,66 +3473,22 @@ nsComponentManagerImpl::RemoveFileInfo(nsIFile *file, const char *loaderString)
if (NS_FAILED(rv))
return rv;
nsCStringKey key(registryName);
AutoRegEntry* entry = (AutoRegEntry*)mAutoRegEntries.Remove(&key);
if (entry)
delete entry;
PRInt32 count = mAutoRegEntries.Count();
for (PRInt32 i = 0; i<count; i++)
{
AutoRegEntry* entry = (AutoRegEntry*) mAutoRegEntries.ElementAt(i);
NS_ASSERTION(entry, "bad entry in array");
if (!strcmp(registryName.get(), entry->GetName()))
{
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)
{

View File

@ -73,6 +73,8 @@ 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
@ -94,6 +96,7 @@ 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
@ -151,6 +154,7 @@ 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,
@ -205,15 +209,10 @@ protected:
PRMonitor* mMon;
nsNativeComponentLoader *mNativeComponentLoader;
#ifdef ENABLE_STATIC_COMPONENT_LOADER
nsIComponentLoader *mStaticComponentLoader;
#endif
nsCOMPtr<nsIFile> mComponentsDir;
PRInt32 mComponentsOffset;
nsCOMPtr<nsIFile> mGREComponentsDir;
PRInt32 mGREComponentsOffset;
// Shutdown
#define NS_SHUTDOWN_NEVERHAPPENED 0
#define NS_SHUTDOWN_INPROGRESS 1
@ -225,7 +224,7 @@ protected:
int mMaxNLoaderData;
PRBool mRegistryDirty;
nsHashtable mAutoRegEntries;
nsVoidArray mAutoRegEntries;
nsCOMPtr<nsICategoryManager> mCategoryManager;
PLArenaPool mArena;
@ -262,6 +261,24 @@ 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()
@ -330,6 +347,7 @@ struct nsContractIDTableEntry : public PLDHashEntryHdr {
class AutoRegEntry
{
public:
AutoRegEntry(){};
AutoRegEntry(const char* name, PRInt64* modDate);
virtual ~AutoRegEntry();
@ -338,14 +356,8 @@ 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__

View File

@ -49,16 +49,13 @@
interface nsIFile;
[uuid(fce83d37-a3c0-4e09-ad9f-6842a984dbdf)]
[scriptable, 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);
};

View File

@ -1,70 +0,0 @@
/* -*- 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);
};

View File

@ -76,9 +76,7 @@ nsNativeComponentLoader::~nsNativeComponentLoader()
delete mDllStore;
}
NS_IMPL_THREADSAFE_ISUPPORTS2(nsNativeComponentLoader,
nsIComponentLoader,
nsINativeComponentLoader);
NS_IMPL_THREADSAFE_ISUPPORTS1(nsNativeComponentLoader, nsIComponentLoader);
NS_IMETHODIMP
nsNativeComponentLoader::GetFactory(const nsIID & aCID,
@ -130,7 +128,13 @@ 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"),
@ -272,6 +276,25 @@ 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,
@ -397,6 +420,21 @@ 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
@ -541,6 +579,19 @@ 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;
}
@ -812,7 +863,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(component, persistentDescriptor);
dll = new nsDll(persistentDescriptor);
if (dll == NULL)
return NS_ERROR_OUT_OF_MEMORY;
mDllStore->Put(&key, (void *) dll);
@ -948,14 +999,19 @@ nsNativeComponentLoader::CreateDll(nsIFile *aSpec,
if (!aSpec)
{
// 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<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(mCompMgr, &rv);
if (obsoleteManager)
rv = obsoleteManager->SpecForRegistryLocation(aLocation,
getter_AddRefs(spec));
if (NS_FAILED(rv))
return rv;
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<nsIComponentManagerObsolete> obsoleteManager = do_QueryInterface(mCompMgr, &rv);
if (obsoleteManager)
rv = obsoleteManager->SpecForRegistryLocation(aLocation,
getter_AddRefs(spec));
if (NS_FAILED(rv))
return rv;
}
}
else
{
@ -990,35 +1046,11 @@ nsNativeComponentLoader::GetFactoryFromModule(nsDll *aDll, const nsCID &aCID,
(void **)aFactory);
}
NS_IMETHODIMP
nsNativeComponentLoader::AddDependentLibrary(nsIFile* aFile, const char* libName)
nsresult
nsNativeComponentLoader::GetFactoryFromNSGetFactory(nsDll *aDll,
const nsCID &aCID,
nsIServiceManager *aServMgr,
nsIFactory **aFactory)
{
nsCOMPtr<nsIComponentLoaderManager> 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;
return NS_ERROR_FACTORY_NOT_LOADED;
}

View File

@ -25,17 +25,15 @@
#include "nsHashtable.h"
#include "nsVoidArray.h"
#include "xcDll.h"
#include "nsINativeComponentLoader.h"
#ifndef nsNativeComponentLoader_h__
#define nsNativeComponentLoader_h__
class nsNativeComponentLoader : public nsIComponentLoader, public nsINativeComponentLoader {
class nsNativeComponentLoader : public nsIComponentLoader {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSICOMPONENTLOADER
NS_DECL_NSINATIVECOMPONENTLOADER
nsNativeComponentLoader();
virtual ~nsNativeComponentLoader();
@ -53,6 +51,11 @@ class nsNativeComponentLoader : public nsIComponentLoader, public nsINativeCompo
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,

View File

@ -49,8 +49,6 @@
#include "nsIComponentLoaderManager.h"
#include "nsIModule.h"
#include "nsILocalFile.h"
#include "nsDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsString.h"
@ -66,22 +64,92 @@
#include "nsNativeComponentLoader.h"
extern nsresult NS_GetComponentLoaderManager(nsIComponentLoaderManager* *result);
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)
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)
{
NS_ASSERTION(registryLocation, "registryLocation is null");
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;
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<nsILocalFile> 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
@ -93,21 +161,43 @@ 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_registryLocation)
return m_registryLocation;
return "unknown!";
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();
}
PRBool
nsDll::HasChanged()
{
if (m_dllName)
return PR_FALSE;
extern nsresult NS_GetComponentLoaderManager(nsIComponentLoaderManager* *result);
nsCOMPtr<nsIComponentLoaderManager> manager;
NS_GetComponentLoaderManager(getter_AddRefs(manager));
if (!manager)
@ -116,8 +206,6 @@ nsDll::HasChanged()
// If mod date has changed, then dll has changed
PRInt64 currentDate;
nsresult rv = m_dllSpec->GetLastModifiedTime(&currentDate);
if (NS_FAILED(rv))
return PR_TRUE;
PRBool changed = PR_TRUE;
manager->HasFileChanged(m_dllSpec, nsnull, currentDate, &changed);
return changed;
@ -140,110 +228,10 @@ PRBool nsDll::Load(void)
#ifdef NS_BUILD_REFCNT_LOGGING
nsTraceRefcnt::SetActivityIsLegal(PR_FALSE);
#endif
nsCOMPtr<nsILocalFile> 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<nsIComponentLoaderManager> manager;
NS_GetComponentLoaderManager(getter_AddRefs(manager));
if (!manager)
return PR_TRUE;
#if defined(XP_UNIX) && !defined(MACOSX)
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<nsIFile> 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);
}
#endif
// load the component
nsCOMPtr<nsILocalFile> lf(do_QueryInterface(m_dllSpec));
NS_ASSERTION(lf, "nsIFile here must implement a nsILocalFile");
lf->Load(&m_instance);
#if defined(XP_UNIX) && !defined(MACOSX)
// 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));
}
#endif
#ifdef NS_BUILD_REFCNT_LOGGING
nsTraceRefcnt::SetActivityIsLegal(PR_TRUE);
if (m_instance) {
@ -255,8 +243,28 @@ 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 SHOULD_IMPLEMENT_BREAKAFTERLOAD
#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)
// 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.
@ -334,10 +342,11 @@ 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 (!m_dllSpec)
// We need a nsIFile for location. If we dont
// have one, create one.
if (!m_dllSpec && m_dllName)
{
return NS_ERROR_FAILURE;
// Create m_dllSpec from m_dllName
}
nsGetModuleProc proc =
@ -355,6 +364,9 @@ 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
@ -382,9 +394,10 @@ 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
@ -431,6 +444,6 @@ void nsDll::BreakAfterLoad(const char *nsprPath)
raise(SIGTRAP);
#endif
}
#endif /* SHOULD_IMPLEMENT_BREAKAFTERLOAD */
return;
}
#endif /* SHOULD_IMPLEMENT_BREAKAFTERLOAD */

View File

@ -53,10 +53,6 @@
#include "nsCOMPtr.h"
#include "nsString.h"
#if defined(DEBUG) && !defined(XP_BEOS)
#define SHOULD_IMPLEMENT_BREAKAFTERLOAD
#endif
class nsIModule;
class nsIServiceManager;
@ -72,25 +68,32 @@ typedef enum nsDllStatus
class nsDll
{
private:
nsCOMPtr<nsIFile> m_dllSpec;
char *m_registryLocation;
PRLibrary *m_instance; // Load instance
char *m_dllName; // Stores the dllName to load.
nsCOMPtr<nsIFile> m_dllSpec; // Filespec representing the component
PRLibrary *m_instance; // Load instance
nsDllStatus m_status; // holds current status
nsIModule *m_moduleObject;
nsIModule *m_moduleObject;
PRBool m_markForUnload;
// Cache frequent queries
nsCString m_persistentDescriptor;
nsCString m_nativePath;
PRBool m_markForUnload;
char *m_registryLocation;
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
@ -116,10 +119,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

View File

@ -52,9 +52,6 @@
#include "nsDirectoryServiceDefs.h"
#include "nsDirectoryService.h"
#include "nsEmbedString.h"
#else
#include "nsIInterfaceRequestorUtils.h"
#include "nsINativeComponentLoader.h"
#endif
nsGenericFactory::nsGenericFactory(const nsModuleComponentInfo *info)
@ -227,16 +224,14 @@ NS_NewGenericFactory(nsIGenericFactory* *result,
nsGenericModule::nsGenericModule(const char* moduleName, PRUint32 componentCount,
const nsModuleComponentInfo* components,
nsModuleConstructorProc ctor,
nsModuleDestructorProc dtor,
const char** aLibDepends)
nsModuleDestructorProc dtor)
: mInitialized(PR_FALSE),
mModuleName(moduleName),
mComponentCount(componentCount),
mComponents(components),
mFactoriesNotToBeRegistered(nsnull),
mCtor(ctor),
mDtor(dtor),
mLibraryDependencies(aLibDepends)
mDtor(dtor)
{
}
@ -465,25 +460,6 @@ 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<nsINativeComponentLoader> 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;
}
@ -538,7 +514,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->mLibraryDependencies);
info->mCtor, info->mDtor);
if (!m)
return NS_ERROR_OUT_OF_MEMORY;
@ -567,7 +543,6 @@ NS_NewGenericModule(const char* moduleName,
info.mComponents = components;
info.mCount = componentCount;
info.mDtor = dtor;
info.mLibraryDependencies = nsnull;
return NS_NewGenericModule2(&info, result);
}

View File

@ -81,8 +81,7 @@ public:
PRUint32 componentCount,
const nsModuleComponentInfo* components,
nsModuleConstructorProc ctor,
nsModuleDestructorProc dtor,
const char** alibDepends);
nsModuleDestructorProc dtor);
virtual ~nsGenericModule();
@ -119,7 +118,6 @@ protected:
FactoryNode* mFactoriesNotToBeRegistered;
nsModuleConstructorProc mCtor;
nsModuleDestructorProc mDtor;
const char** mLibraryDependencies;
};
#endif /* nsGenericFactory_h___ */

View File

@ -277,8 +277,6 @@ 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.
*
**/
@ -289,7 +287,6 @@ struct nsModuleInfo {
PRUint32 mCount;
nsModuleConstructorProc mCtor;
nsModuleDestructorProc mDtor;
const char** mLibraryDependencies;
};
/**
@ -297,7 +294,7 @@ struct nsModuleInfo {
* binary compatibility. (Ostensibly fix NS_NewGenericModule2() to deal
* with older rev's at the same time.)
*/
#define NS_MODULEINFO_VERSION 0x00015000UL // 1.5
#define NS_MODULEINFO_VERSION 0x00010000UL // 1.0
/**
* Create a new generic module. Use the NS_IMPL_NSGETMODULE macro, or
@ -353,8 +350,7 @@ nsModuleInfo NSMODULEINFO(_name) = { \
(_components), \
(sizeof(_components) / sizeof(_components[0])), \
(_ctor), \
(_dtor), \
(nsnull) \
(_dtor) \
}; \
NSGETMODULE_ENTRY_POINT(NSMODULEINFO(_name))

View File

@ -131,7 +131,6 @@ PRBool xptiManifest::Write(xptiInterfaceInfoManager* aMgr,
PRUint32 size32;
PRIntn interfaceCount = 0;
nsCAutoString appDirString;
nsCOMPtr<nsIFile> greDirectory;
nsCOMPtr<nsILocalFile> tempFile;
if(!aMgr->GetCloneOfManifestDir(getter_AddRefs(tempFile)) || !tempFile)
@ -178,8 +177,6 @@ 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<nsILocalFile> dir;
@ -189,19 +186,9 @@ PRBool xptiManifest::Write(xptiInterfaceInfoManager* aMgr,
if(!dir)
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;
}
dir->GetPersistentDescriptor(str);
if(str.IsEmpty())
goto out;
if(!PR_fprintf(fd, "%d,%s\n", (int) i, str.get()))
goto out;
@ -504,8 +491,6 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
for(i = 0; i < dirCount; ++i)
{
nsCAutoString str;
if(!reader.NextLine())
goto out;
@ -517,23 +502,8 @@ PRBool xptiManifest::Read(xptiInterfaceInfoManager* aMgr,
if(i != atoi(values[0]))
goto out;
if (strcmp(values[1], "gre"))
{
nsCOMPtr<nsIFile> greDirectory;
NS_GetSpecialDirectory(NS_GRE_COMPONENT_DIR, getter_AddRefs(greDirectory));
nsCOMPtr<nsILocalFile> lFile = do_QueryInterface(greDirectory);
if (!lFile)
goto out;
lFile->GetPersistentDescriptor(str);
}
else
{
str = values[1];
}
// directoryname
if(!aWorkingSet->DirectoryAtMatchesPersistentDescriptor(i, str.get()))
if(!aWorkingSet->DirectoryAtMatchesPersistentDescriptor(i, values[1]))
goto out;
}