Bug 710112 - cleanup xpcom/io for windows (reduce LoadLibrary/PR_LoadLibrary). r=jimm

This commit is contained in:
Makoto Kato 2012-01-16 10:54:20 +09:00
Родитель 285e8ffe45
Коммит 07fb70e23f
5 изменённых файлов: 10 добавлений и 32 удалений

Просмотреть файл

@ -717,8 +717,6 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
nsComponentManagerImpl::gComponentManager = nsnull;
nsCategoryManager::Destroy();
ShutdownSpecialSystemDirectory();
NS_PurgeAtomTable();
NS_IF_RELEASE(gDebug);

Просмотреть файл

@ -101,8 +101,6 @@ typedef HRESULT (WINAPI* nsGetKnownFolderPath)(GUID& rfid,
PWSTR *ppszPath);
static nsGetKnownFolderPath gGetKnownFolderPath = NULL;
static HINSTANCE gShell32DLLInst = NULL;
#endif
void StartupSpecialSystemDirectory()
@ -110,23 +108,11 @@ void StartupSpecialSystemDirectory()
#if defined (XP_WIN)
// SHGetKnownFolderPath is only available on Windows Vista
// so that we need to use GetProcAddress to get the pointer.
gShell32DLLInst = LoadLibraryW(L"shell32.dll");
if(gShell32DLLInst)
HMODULE hShell32DLLInst = GetModuleHandleW(L"shell32.dll");
if(hShell32DLLInst)
{
gGetKnownFolderPath = (nsGetKnownFolderPath)
GetProcAddress(gShell32DLLInst, "SHGetKnownFolderPath");
}
#endif
}
void ShutdownSpecialSystemDirectory()
{
#if defined (XP_WIN)
if (gShell32DLLInst)
{
FreeLibrary(gShell32DLLInst);
gShell32DLLInst = NULL;
gGetKnownFolderPath = NULL;
GetProcAddress(hShell32DLLInst, "SHGetKnownFolderPath");
}
#endif
}

Просмотреть файл

@ -51,7 +51,6 @@
#endif
extern void StartupSpecialSystemDirectory();
extern void ShutdownSpecialSystemDirectory();
enum SystemDirectories {

Просмотреть файл

@ -108,7 +108,6 @@ unsigned char *_mbsstr( const unsigned char *str,
ILCreateFromPathWPtr nsLocalFile::sILCreateFromPathW = NULL;
SHOpenFolderAndSelectItemsPtr nsLocalFile::sSHOpenFolderAndSelectItems = NULL;
PRLibrary *nsLocalFile::sLibShell = NULL;
class nsDriveEnumerator : public nsISimpleEnumerator
{
@ -2773,7 +2772,7 @@ nsLocalFile::RevealUsingShell()
{
// All of these shell32.dll related pointers should be non NULL
// on XP and later.
if (!sLibShell || !sILCreateFromPathW || !sSHOpenFolderAndSelectItems) {
if (!sILCreateFromPathW || !sSHOpenFolderAndSelectItems) {
return NS_ERROR_FAILURE;
}
@ -3134,26 +3133,23 @@ nsLocalFile::GlobalInit()
// shell32.dll should be loaded already, so we are not actually
// loading the library here.
sLibShell = PR_LoadLibrary("shell32.dll");
if (sLibShell) {
HMODULE hLibShell = GetModuleHandleW(L"shell32.dll");
if (hLibShell) {
// ILCreateFromPathW is available in XP and up.
sILCreateFromPathW = (ILCreateFromPathWPtr)
PR_FindFunctionSymbol(sLibShell,
"ILCreateFromPathW");
GetProcAddress(hLibShell,
"ILCreateFromPathW");
// SHOpenFolderAndSelectItems is available in XP and up.
sSHOpenFolderAndSelectItems = (SHOpenFolderAndSelectItemsPtr)
PR_FindFunctionSymbol(sLibShell,
"SHOpenFolderAndSelectItems");
GetProcAddress(hLibShell,
"SHOpenFolderAndSelectItems");
}
}
void
nsLocalFile::GlobalShutdown()
{
if (sLibShell) {
PR_UnloadLibrary(sLibShell);
}
NS_DestroyShortcutResolver();
}

Просмотреть файл

@ -133,7 +133,6 @@ private:
static ILCreateFromPathWPtr sILCreateFromPathW;
static SHOpenFolderAndSelectItemsPtr sSHOpenFolderAndSelectItems;
static PRLibrary *sLibShell;
};
#endif