diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index f054daf05a9..eba6390d8c6 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -2879,16 +2879,11 @@ nsComponentManagerImpl::AutoRegisterImpl(PRInt32 when, nsIFile *inDirSpec) if (!iim) return NS_ERROR_UNEXPECTED; - - // Startup any category observers that may want to listen to autoreg - NS_CreateServicesFromCategory("xpcom-observers", - nsnull, - NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID); - + // Notify observers of xpcom autoregistration start nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1", &rv); - if (NS_SUCCEEDED(rv)) + if (NS_FAILED(rv)) { // NO COMPtr as we dont release the service manager nsIServiceManager *mgr = NS_STATIC_CAST(nsIServiceManager*, this); diff --git a/xpcom/io/nsLocalFileMac.cpp b/xpcom/io/nsLocalFileMac.cpp index 3353f9e80aa..6a1acdee80d 100644 --- a/xpcom/io/nsLocalFileMac.cpp +++ b/xpcom/io/nsLocalFileMac.cpp @@ -2485,23 +2485,24 @@ NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL) rv = GetPath(&ePath); if (NS_SUCCEEDED(rv)) { - SwapSlashColon(ePath); - // Escape the path with the directory mask - rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath); - if (NS_SUCCEEDED(rv)) { - escPath.Insert("file:///", 0); - if (escPath[escPath.Length() - 1] != '/') { - PRBool dir; - rv = IsDirectory(&dir); - NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); - if (NS_SUCCEEDED(rv) && dir) { - // make sure we have a trailing slash - escPath += "/"; - } + SwapSlashColon(ePath); + + // Escape the path with the directory mask + rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath); + if (NS_SUCCEEDED(rv)) { + + escPath.Insert("file:///", 0); + + PRBool dir; + rv = IsDirectory(&dir); + NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); + if (NS_SUCCEEDED(rv) && dir && escPath[escPath.Length() - 1] != '/') { + // make sure we have a trailing slash + escPath += "/"; + } + *aURL = nsCRT::strdup((const char *)escPath); + rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } - *aURL = nsCRT::strdup((const char *)escPath); - rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; - } } CRTFREEIF(ePath); return rv; diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index c25341ce290..071394d2c47 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -1425,23 +1425,22 @@ NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL) rv = GetPath(&ePath); if (NS_SUCCEEDED(rv)) { - SwapSlashColon(ePath); // Escape the path with the directory mask rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath); if (NS_SUCCEEDED(rv)) { - escPath.Insert("file:///", 0); - if (escPath[escPath.Length() - 1] != '/') { - PRBool dir; - rv = IsDirectory(&dir); - NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); - if (NS_SUCCEEDED(rv) && dir) { - // make sure we have a trailing slash - escPath += "/"; - } + + escPath.Insert("file://", 0); + + PRBool dir; + rv = IsDirectory(&dir); + NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory"); + if (NS_SUCCEEDED(rv) && dir && escPath[escPath.Length() - 1] != '/') { + // make sure we have a trailing slash + escPath += "/"; } *aURL = ToNewCString(escPath); rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY; - } + } } CRTFREEIF(ePath); return rv; diff --git a/xpcom/io/nsSpecialSystemDirectory.cpp b/xpcom/io/nsSpecialSystemDirectory.cpp index 8ba75700350..16794625270 100644 --- a/xpcom/io/nsSpecialSystemDirectory.cpp +++ b/xpcom/io/nsSpecialSystemDirectory.cpp @@ -120,42 +120,8 @@ PR_STATIC_CALLBACK(PRBool) DeleteSystemDirKeys(nsHashKey *aKey, void *aData, voi #define NS_SYSTEMDIR_HASH_NUM (10) static nsHashtable *systemDirectoriesLocations = NULL; -#if defined (XP_WIN) -typedef BOOL (WINAPI * GetSpecialPathProc) (HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate); -GetSpecialPathProc gGetSpecialPathProc = NULL; -static HINSTANCE gShell32DLLInst = NULL; -#endif -NS_COM void StartupSpecialSystemDirectory() -{ -#if defined (XP_WIN) - /* On windows, the old method to get file locations is incredibly slow. - As of this writting, 3 calls to GetWindowsFolder accounts for 3% of mozilla - startup. Replacing these older calls with a single call to SHGetSpecialFolderPath - effectively removes these calls from the performace radar. We need to - support the older way of file location lookup on systems that do not have - IE4. - */ - gShell32DLLInst = LoadLibrary("shfolder.dll"); - if(gShell32DLLInst) - { - gGetSpecialPathProc = (GetSpecialPathProc) GetProcAddress(gShell32DLLInst, - "SHGetSpecialFolderPath"); - } - - if (!gGetSpecialPathProc) - { - if (gShell32DLLInst) - FreeLibrary(gShell32DLLInst); - gShell32DLLInst = LoadLibrary("Shell32.dll"); - if(gShell32DLLInst) - { - gGetSpecialPathProc = (GetSpecialPathProc) GetProcAddress(gShell32DLLInst, - "SHGetSpecialFolderPath"); - } - } -#endif -} +NS_COM void StartupSpecialSystemDirectory(){} NS_COM void ShutdownSpecialSystemDirectory() { @@ -164,14 +130,6 @@ NS_COM void ShutdownSpecialSystemDirectory() systemDirectoriesLocations->Reset(DeleteSystemDirKeys); delete systemDirectoriesLocations; } -#if defined (XP_WIN) - if (gShell32DLLInst) - { - FreeLibrary(gShell32DLLInst); - gShell32DLLInst = NULL; - gGetSpecialPathProc = NULL; - } -#endif } #if defined (XP_WIN) @@ -219,25 +177,6 @@ static char* MakeUpperCase(char* aPath) static void GetWindowsFolder(int folder, nsFileSpec& outDirectory) //---------------------------------------------------------------------------------------- { - - if (gGetSpecialPathProc) { - TCHAR path[MAX_PATH]; - HRESULT result = gGetSpecialPathProc(NULL, path, folder, true); - - if (!SUCCEEDED(result)) - return; - - // Append the trailing slash - int len = PL_strlen(path); - if (len>1 && path[len-1] != '\\') - { - path[len] = '\\'; - path[len + 1] = '\0'; - } - outDirectory = path; - return; - } - LPMALLOC pMalloc = NULL; LPSTR pBuffer = NULL; LPITEMIDLIST pItemIDList = NULL; diff --git a/xpcom/tests/TestShutdown.cpp b/xpcom/tests/TestShutdown.cpp index 7e66a2370f0..64ccd5c06ac 100644 --- a/xpcom/tests/TestShutdown.cpp +++ b/xpcom/tests/TestShutdown.cpp @@ -71,9 +71,6 @@ void main(int argc, char* argv[]) else { printf("Failed to create %s (%x)\n", cidStr, rv); } - - nsComponentManager::FreeLibraries(); - } rv = NS_ShutdownXPCOM(servMgr);