Skip to content

Commit e03c679

Browse files
author
dougt%netscape.com
committed
Moving nsISimpleEnumeratory interface into a seperate idl file. bug 99136. r=alecf@netscape.com, sr=rpotts@netscape.com
1 parent 1fc3994 commit e03c679

File tree

9 files changed

+103
-31
lines changed

9 files changed

+103
-31
lines changed

xpcom/components/nsComponentManager.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,11 +2879,16 @@ nsComponentManagerImpl::AutoRegisterImpl(PRInt32 when, nsIFile *inDirSpec)
28792879

28802880
if (!iim)
28812881
return NS_ERROR_UNEXPECTED;
2882-
2882+
2883+
// Startup any category observers that may want to listen to autoreg
2884+
NS_CreateServicesFromCategory("xpcom-observers",
2885+
nsnull,
2886+
NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID);
2887+
28832888
// Notify observers of xpcom autoregistration start
28842889
nsCOMPtr<nsIObserverService> observerService =
28852890
do_GetService("@mozilla.org/observer-service;1", &rv);
2886-
if (NS_FAILED(rv))
2891+
if (NS_SUCCEEDED(rv))
28872892
{
28882893
// NO COMPtr as we dont release the service manager
28892894
nsIServiceManager *mgr = NS_STATIC_CAST(nsIServiceManager*, this);

xpcom/components/nsICategoryManager.idl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
#include "nsISupports.idl"
20-
#include "nsIEnumerator.idl"
20+
#include "nsISimpleEnumerator.idl"
2121
#include "nsICategoryHandler.idl"
2222
#include "nsIFactory.idl"
2323

xpcom/ds/MANIFEST_IDL

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ nsIObserverService.idl
77
nsIPersistentProperties2.idl
88
nsIProperties.idl
99
nsISerializable.idl
10+
nsISimpleEnumerator.idl
1011
nsIStopwatch.idl
1112
nsISupportsArray.idl
1213
nsITimelineService.idl

xpcom/ds/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ XPIDLSRCS = \
113113
nsIPersistentProperties2.idl \
114114
nsIProperties.idl \
115115
nsISerializable.idl \
116+
nsISimpleEnumerator.idl \
116117
nsIStopwatch.idl \
117118
nsISupportsArray.idl \
118119
nsISupportsIterators.idl \

xpcom/ds/makefile.win

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ XPIDLSRCS = \
7474
.\nsITimelineService.idl \
7575
.\nsIProperties.idl \
7676
.\nsISerializable.idl \
77+
.\nsISimpleEnumerator.idl \
7778
.\nsIStopwatch.idl \
7879
.\nsISupportsArray.idl \
7980
.\nsISupportsIterators.idl \

xpcom/io/nsLocalFileMac.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,24 +2485,23 @@ NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL)
24852485
rv = GetPath(&ePath);
24862486
if (NS_SUCCEEDED(rv)) {
24872487

2488-
SwapSlashColon(ePath);
2489-
2490-
// Escape the path with the directory mask
2491-
rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath);
2492-
if (NS_SUCCEEDED(rv)) {
2493-
2494-
escPath.Insert("file:///", 0);
2495-
2496-
PRBool dir;
2497-
rv = IsDirectory(&dir);
2498-
NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory");
2499-
if (NS_SUCCEEDED(rv) && dir && escPath[escPath.Length() - 1] != '/') {
2500-
// make sure we have a trailing slash
2501-
escPath += "/";
2502-
}
2503-
*aURL = nsCRT::strdup((const char *)escPath);
2504-
rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
2488+
SwapSlashColon(ePath);
2489+
// Escape the path with the directory mask
2490+
rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath);
2491+
if (NS_SUCCEEDED(rv)) {
2492+
escPath.Insert("file:///", 0);
2493+
if (escPath[escPath.Length() - 1] != '/') {
2494+
PRBool dir;
2495+
rv = IsDirectory(&dir);
2496+
NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory");
2497+
if (NS_SUCCEEDED(rv) && dir) {
2498+
// make sure we have a trailing slash
2499+
escPath += "/";
2500+
}
25052501
}
2502+
*aURL = nsCRT::strdup((const char *)escPath);
2503+
rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
2504+
}
25062505
}
25072506
CRTFREEIF(ePath);
25082507
return rv;

xpcom/io/nsLocalFileUnix.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,22 +1425,23 @@ NS_IMETHODIMP nsLocalFile::GetURL(char * *aURL)
14251425
rv = GetPath(&ePath);
14261426
if (NS_SUCCEEDED(rv)) {
14271427

1428+
SwapSlashColon(ePath);
14281429
// Escape the path with the directory mask
14291430
rv = nsStdEscape(ePath, esc_Directory+esc_Forced, escPath);
14301431
if (NS_SUCCEEDED(rv)) {
1431-
1432-
escPath.Insert("file://", 0);
1433-
1434-
PRBool dir;
1435-
rv = IsDirectory(&dir);
1436-
NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory");
1437-
if (NS_SUCCEEDED(rv) && dir && escPath[escPath.Length() - 1] != '/') {
1438-
// make sure we have a trailing slash
1439-
escPath += "/";
1432+
escPath.Insert("file:///", 0);
1433+
if (escPath[escPath.Length() - 1] != '/') {
1434+
PRBool dir;
1435+
rv = IsDirectory(&dir);
1436+
NS_ASSERTION(NS_SUCCEEDED(rv), "Cannot tell if this is a directory");
1437+
if (NS_SUCCEEDED(rv) && dir) {
1438+
// make sure we have a trailing slash
1439+
escPath += "/";
1440+
}
14401441
}
14411442
*aURL = ToNewCString(escPath);
14421443
rv = *aURL ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
1443-
}
1444+
}
14441445
}
14451446
CRTFREEIF(ePath);
14461447
return rv;

xpcom/io/nsSpecialSystemDirectory.cpp

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,42 @@ PR_STATIC_CALLBACK(PRBool) DeleteSystemDirKeys(nsHashKey *aKey, void *aData, voi
120120

121121
#define NS_SYSTEMDIR_HASH_NUM (10)
122122
static nsHashtable *systemDirectoriesLocations = NULL;
123+
#if defined (XP_WIN)
124+
typedef BOOL (WINAPI * GetSpecialPathProc) (HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
125+
GetSpecialPathProc gGetSpecialPathProc = NULL;
126+
static HINSTANCE gShell32DLLInst = NULL;
127+
#endif
128+
NS_COM void StartupSpecialSystemDirectory()
129+
{
130+
#if defined (XP_WIN)
131+
/* On windows, the old method to get file locations is incredibly slow.
132+
As of this writting, 3 calls to GetWindowsFolder accounts for 3% of mozilla
133+
startup. Replacing these older calls with a single call to SHGetSpecialFolderPath
134+
effectively removes these calls from the performace radar. We need to
135+
support the older way of file location lookup on systems that do not have
136+
IE4.
137+
*/
138+
gShell32DLLInst = LoadLibrary("shfolder.dll");
139+
if(gShell32DLLInst)
140+
{
141+
gGetSpecialPathProc = (GetSpecialPathProc) GetProcAddress(gShell32DLLInst,
142+
"SHGetSpecialFolderPath");
143+
}
144+
145+
if (!gGetSpecialPathProc)
146+
{
147+
if (gShell32DLLInst)
148+
FreeLibrary(gShell32DLLInst);
123149

124-
NS_COM void StartupSpecialSystemDirectory(){}
150+
gShell32DLLInst = LoadLibrary("Shell32.dll");
151+
if(gShell32DLLInst)
152+
{
153+
gGetSpecialPathProc = (GetSpecialPathProc) GetProcAddress(gShell32DLLInst,
154+
"SHGetSpecialFolderPath");
155+
}
156+
}
157+
#endif
158+
}
125159

126160
NS_COM void ShutdownSpecialSystemDirectory()
127161
{
@@ -130,6 +164,14 @@ NS_COM void ShutdownSpecialSystemDirectory()
130164
systemDirectoriesLocations->Reset(DeleteSystemDirKeys);
131165
delete systemDirectoriesLocations;
132166
}
167+
#if defined (XP_WIN)
168+
if (gShell32DLLInst)
169+
{
170+
FreeLibrary(gShell32DLLInst);
171+
gShell32DLLInst = NULL;
172+
gGetSpecialPathProc = NULL;
173+
}
174+
#endif
133175
}
134176

135177
#if defined (XP_WIN)
@@ -177,6 +219,25 @@ static char* MakeUpperCase(char* aPath)
177219
static void GetWindowsFolder(int folder, nsFileSpec& outDirectory)
178220
//----------------------------------------------------------------------------------------
179221
{
222+
223+
if (gGetSpecialPathProc) {
224+
TCHAR path[MAX_PATH];
225+
HRESULT result = gGetSpecialPathProc(NULL, path, folder, true);
226+
227+
if (!SUCCEEDED(result))
228+
return;
229+
230+
// Append the trailing slash
231+
int len = PL_strlen(path);
232+
if (len>1 && path[len-1] != '\\')
233+
{
234+
path[len] = '\\';
235+
path[len + 1] = '\0';
236+
}
237+
outDirectory = path;
238+
return;
239+
}
240+
180241
LPMALLOC pMalloc = NULL;
181242
LPSTR pBuffer = NULL;
182243
LPITEMIDLIST pItemIDList = NULL;

xpcom/tests/TestShutdown.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ void main(int argc, char* argv[])
7171
else {
7272
printf("Failed to create %s (%x)\n", cidStr, rv);
7373
}
74+
75+
nsComponentManager::FreeLibraries();
76+
7477
}
7578

7679
rv = NS_ShutdownXPCOM(servMgr);

0 commit comments

Comments
 (0)