Moving nsISimpleEnumeratory interface into a seperate idl file. bug 99136. r=alecf@netscape.com, sr=rpotts@netscape.com

git-svn-id: svn://10.0.0.236/trunk@106715 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dougt%netscape.com 2001-10-30 22:03:05 +00:00
parent fad8f3eb7f
commit 3e064cf384
9 changed files with 103 additions and 31 deletions

View File

@ -2879,11 +2879,16 @@ 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<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_FAILED(rv))
if (NS_SUCCEEDED(rv))
{
// NO COMPtr as we dont release the service manager
nsIServiceManager *mgr = NS_STATIC_CAST(nsIServiceManager*, this);

View File

@ -17,7 +17,7 @@
*/
#include "nsISupports.idl"
#include "nsIEnumerator.idl"
#include "nsISimpleEnumerator.idl"
#include "nsICategoryHandler.idl"
#include "nsIFactory.idl"

View File

@ -7,6 +7,7 @@ nsIObserverService.idl
nsIPersistentProperties2.idl
nsIProperties.idl
nsISerializable.idl
nsISimpleEnumerator.idl
nsIStopwatch.idl
nsISupportsArray.idl
nsITimelineService.idl

View File

@ -113,6 +113,7 @@ XPIDLSRCS = \
nsIPersistentProperties2.idl \
nsIProperties.idl \
nsISerializable.idl \
nsISimpleEnumerator.idl \
nsIStopwatch.idl \
nsISupportsArray.idl \
nsISupportsIterators.idl \

View File

@ -74,6 +74,7 @@ XPIDLSRCS = \
.\nsITimelineService.idl \
.\nsIProperties.idl \
.\nsISerializable.idl \
.\nsISimpleEnumerator.idl \
.\nsIStopwatch.idl \
.\nsISupportsArray.idl \
.\nsISupportsIterators.idl \

View File

@ -2485,24 +2485,23 @@ 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);
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;
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 += "/";
}
}
*aURL = nsCRT::strdup((const char *)escPath);
rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
}
CRTFREEIF(ePath);
return rv;

View File

@ -1425,22 +1425,23 @@ 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);
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 += "/";
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 += "/";
}
}
*aURL = ToNewCString(escPath);
rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
}
}
CRTFREEIF(ePath);
return rv;

View File

@ -120,8 +120,42 @@ 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);
NS_COM void StartupSpecialSystemDirectory(){}
gShell32DLLInst = LoadLibrary("Shell32.dll");
if(gShell32DLLInst)
{
gGetSpecialPathProc = (GetSpecialPathProc) GetProcAddress(gShell32DLLInst,
"SHGetSpecialFolderPath");
}
}
#endif
}
NS_COM void ShutdownSpecialSystemDirectory()
{
@ -130,6 +164,14 @@ 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)
@ -177,6 +219,25 @@ 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;

View File

@ -71,6 +71,9 @@ void main(int argc, char* argv[])
else {
printf("Failed to create %s (%x)\n", cidStr, rv);
}
nsComponentManager::FreeLibraries();
}
rv = NS_ShutdownXPCOM(servMgr);