зеркало из https://github.com/mozilla/pjs.git
Delete gVolumeList on shutdown. b=397305 r+sr+a1.9=bzbarsky
This commit is contained in:
Родитель
b4b6a75851
Коммит
8fb0165c94
|
@ -67,6 +67,9 @@ enum netCoalesceFlags
|
|||
|
||||
/* shutdown frees URL parser */
|
||||
NS_HIDDEN_(void) net_ShutdownURLHelper();
|
||||
#ifdef XP_MACOSX
|
||||
NS_HIDDEN_(void) net_ShutdownURLHelperOSX();
|
||||
#endif
|
||||
|
||||
/* access URL parsers */
|
||||
NS_HIDDEN_(nsIURLParser *) net_GetAuthURLParser();
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Unix-specific local file uri parsing */
|
||||
/* Mac OS X-specific local file uri parsing */
|
||||
#include "nsURLHelper.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
@ -47,6 +47,8 @@
|
|||
#include "nsReadableUtils.h"
|
||||
#include <Files.h>
|
||||
|
||||
static nsCStringArray *gVolumeList = nsnull;
|
||||
|
||||
static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPathComponent)
|
||||
{
|
||||
// Return whether the 1st path component in path (escaped) is equal to the name
|
||||
|
@ -54,10 +56,15 @@ static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPat
|
|||
// This needs to be done as quickly as possible, so we cache a list of volume names.
|
||||
// XXX Register an event handler to detect drives being mounted/unmounted?
|
||||
|
||||
static nsCStringArray gVolumeList; // We will leak this - one for the life of the app :-/
|
||||
if (!gVolumeList) {
|
||||
gVolumeList = new nsCStringArray;
|
||||
if (!gVolumeList) {
|
||||
return PR_FALSE; // out of memory
|
||||
}
|
||||
}
|
||||
|
||||
// Cache a list of volume names
|
||||
if (!gVolumeList.Count()) {
|
||||
if (!gVolumeList->Count()) {
|
||||
OSErr err;
|
||||
ItemCount volumeIndex = 1;
|
||||
|
||||
|
@ -68,7 +75,7 @@ static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPat
|
|||
if (err == noErr) {
|
||||
NS_ConvertUTF16toUTF8 volNameStr(Substring((PRUnichar *)volName.unicode,
|
||||
(PRUnichar *)volName.unicode + volName.length));
|
||||
gVolumeList.AppendCString(volNameStr);
|
||||
gVolumeList->AppendCString(volNameStr);
|
||||
volumeIndex++;
|
||||
}
|
||||
} while (err == noErr);
|
||||
|
@ -85,11 +92,18 @@ static PRBool pathBeginsWithVolName(const nsACString& path, nsACString& firstPat
|
|||
|
||||
nsCAutoString flatComponent((Substring(start, component_end)));
|
||||
NS_UnescapeURL(flatComponent);
|
||||
PRInt32 foundIndex = gVolumeList.IndexOf(flatComponent);
|
||||
PRInt32 foundIndex = gVolumeList->IndexOf(flatComponent);
|
||||
firstPathComponent = flatComponent;
|
||||
return (foundIndex != -1);
|
||||
}
|
||||
|
||||
void
|
||||
net_ShutdownURLHelperOSX()
|
||||
{
|
||||
delete gVolumeList;
|
||||
gVolumeList = nsnull;
|
||||
}
|
||||
|
||||
static nsresult convertHFSPathtoPOSIX(const nsACString& hfsPath, nsACString& posixPath)
|
||||
{
|
||||
// Use CFURL to do the conversion. We don't want to do this by simply
|
||||
|
|
|
@ -605,6 +605,9 @@ static void PR_CALLBACK nsNetShutdown(nsIModule *neckoModule)
|
|||
|
||||
// Release global state used by the URL helper module.
|
||||
net_ShutdownURLHelper();
|
||||
#ifdef XP_MACOSX
|
||||
net_ShutdownURLHelperOSX();
|
||||
#endif
|
||||
|
||||
// Release necko strings
|
||||
delete gNetStrings;
|
||||
|
|
Загрузка…
Ссылка в новой задаче