diff --git a/xpcom/components/nsIComponentRegistrar.idl b/xpcom/components/nsIComponentRegistrar.idl index ec7ce5ccc6c8..1dcf202e3c52 100644 --- a/xpcom/components/nsIComponentRegistrar.idl +++ b/xpcom/components/nsIComponentRegistrar.idl @@ -56,6 +56,8 @@ interface nsIComponentRegistrar : nsISupports * symbols which this loader defines. For example, if the given file is a * native library (which is built into XPCOM), it must export the symbol * "NSGetModule". Other loaders may have different semantics. + * + * This method may only be called from the main thread. * * @param aSpec : Filename spec for component file's location. If aSpec * is a directory, then every component file in the @@ -73,6 +75,7 @@ interface nsIComponentRegistrar : nsISupports * autoUnregister * * Unregister a component file or all component files in a directory. + * This method may only be called from the main thread. * * @param aSpec : Filename spec for component file's location. If aSpec * is a directory, the every component file in the directory diff --git a/xpcom/components/nsNativeComponentLoader.cpp b/xpcom/components/nsNativeComponentLoader.cpp index 45bc49a2ac6e..79b1766d5adc 100644 --- a/xpcom/components/nsNativeComponentLoader.cpp +++ b/xpcom/components/nsNativeComponentLoader.cpp @@ -41,7 +41,6 @@ #include "nsHashtableEnumerator.h" #include "nsXPIDLString.h" #include "nsCRT.h" - #include "nsIObserverService.h" #if defined(XP_MAC) // sdagley dougt fix @@ -87,7 +86,7 @@ nsNativeComponentLoader::~nsNativeComponentLoader() delete mDllStore; } -NS_IMPL_ISUPPORTS1(nsNativeComponentLoader, nsIComponentLoader); +NS_IMPL_THREADSAFE_ISUPPORTS1(nsNativeComponentLoader, nsIComponentLoader); NS_IMETHODIMP nsNativeComponentLoader::GetFactory(const nsIID & aCID, @@ -180,14 +179,17 @@ nsNativeComponentLoader::Init(nsIComponentManager *aCompMgr, nsISupports *aReg) if (NS_FAILED(rv)) return rv; - if (!mDllStore) { - mDllStore = new nsObjectHashtable(nsnull, nsnull, // never copy - nsDll_Destroy, nsnull, - 256, /* Thead Safe */ PR_TRUE); - if (!mDllStore) - return NS_ERROR_OUT_OF_MEMORY; - } + NS_ASSERTION(!mDllStore, "Init must not be called more than once"); + + mDllStore = new nsObjectHashtable(nsnull, + nsnull, // never copy + nsDll_Destroy, + nsnull, + 256, + PR_TRUE); // thread safe + if (!mDllStore) + return NS_ERROR_OUT_OF_MEMORY; // Read in all dll entries and populate the mDllStore nsCOMPtr dllEnum; @@ -979,13 +981,14 @@ nsNativeComponentLoader::RegisterDeferredComponents(PRInt32 aWhen, mDeferredComponents.RemoveElementAt(i); } } - +#ifdef DEBUG if (*aRegistered) fprintf(stderr, "nNCL: registered deferred, %d left\n", mDeferredComponents.Count()); else fprintf(stderr, "nNCL: didn't register any components, %d left\n", mDeferredComponents.Count()); +#endif /* are there any fatal errors? */ return NS_OK; }