Bug 303506 - make xpcom nsDirectoryService assertions more meaningful, r=dougt,sr=shaver

This commit is contained in:
bob%bclary.com 2005-09-04 19:10:10 +00:00
Родитель 555d7f8815
Коммит f6055ed791
1 изменённых файлов: 18 добавлений и 16 удалений

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

@ -235,8 +235,8 @@ nsDirectoryService::GetCurrentProcessDirectory(nsILocalFile** aFile)
// In the absence of a good way to get the executable directory let // In the absence of a good way to get the executable directory let
// us try this for unix: // us try this for unix:
// - if MOZILLA_FIVE_HOME is defined, that is it // - if MOZILLA_FIVE_HOME is defined, that is it
// - else give the current directory // - else give the current directory
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
// The MOZ_DEFAULT_MOZILLA_FIVE_HOME variable can be set at configure time with // The MOZ_DEFAULT_MOZILLA_FIVE_HOME variable can be set at configure time with
@ -512,14 +512,15 @@ static const nsStaticAtom directory_atoms[] = {
NS_IMETHODIMP NS_IMETHODIMP
nsDirectoryService::Init() nsDirectoryService::Init()
{ {
NS_NOTREACHED("Don't call me, I was for internal use only!"); NS_NOTREACHED("nsDirectoryService::Init() for internal use only!");
return NS_OK; return NS_OK;
} }
nsresult nsresult
nsDirectoryService::RealInit() nsDirectoryService::RealInit()
{ {
NS_ASSERTION(!gService, "Mustn't initialize twice!"); NS_ASSERTION(!gService,
"nsDirectoryService::RealInit Mustn't initialize twice!");
nsresult rv; nsresult rv;
@ -650,7 +651,8 @@ nsDirectoryService::Get(const char* prop, const nsIID & uuid, void* *result)
{ {
nsCOMPtr<nsIFile> cloneFile; nsCOMPtr<nsIFile> cloneFile;
nsCOMPtr<nsIFile> cachedFile = do_QueryInterface(value); nsCOMPtr<nsIFile> cachedFile = do_QueryInterface(value);
NS_ASSERTION(cachedFile, "nsIFile expected"); NS_ASSERTION(cachedFile,
"nsDirectoryService::Get nsIFile expected");
cachedFile->Clone(getter_AddRefs(cloneFile)); cachedFile->Clone(getter_AddRefs(cloneFile));
return cloneFile->QueryInterface(uuid, result); return cloneFile->QueryInterface(uuid, result);
@ -796,15 +798,15 @@ nsDirectoryService::UnregisterProvider(nsIDirectoryServiceProvider *prov)
NS_IMETHODIMP NS_IMETHODIMP
nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_retval) nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_retval)
{ {
nsCOMPtr<nsILocalFile> localFile; nsCOMPtr<nsILocalFile> localFile;
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
*_retval = nsnull; *_retval = nsnull;
*persistent = PR_TRUE; *persistent = PR_TRUE;
nsIAtom* inAtom = NS_NewAtom(prop); nsIAtom* inAtom = NS_NewAtom(prop);
// check to see if it is one of our defaults // check to see if it is one of our defaults
if (inAtom == nsDirectoryService::sCurrentProcess || if (inAtom == nsDirectoryService::sCurrentProcess ||
inAtom == nsDirectoryService::sOS_CurrentProcessDirectory ) inAtom == nsDirectoryService::sOS_CurrentProcessDirectory )
@ -849,7 +851,7 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret
{ {
rv = GetCurrentProcessDirectory(getter_AddRefs(localFile)); rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
if (localFile) if (localFile)
localFile->AppendNative(COMPONENT_DIRECTORY); localFile->AppendNative(COMPONENT_DIRECTORY);
} }
else if (inAtom == nsDirectoryService::sOS_DriveDirectory) else if (inAtom == nsDirectoryService::sOS_DriveDirectory)
{ {
@ -950,7 +952,7 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret
{ {
ICAttr attrs; ICAttr attrs;
ICFileSpec icFileSpec; ICFileSpec icFileSpec;
long size = kICFileSpecHeaderSize; long size = kICFileSpecHeaderSize;
err = ::ICGetPref(icInstance, kICDownloadFolder, &attrs, &icFileSpec, &size); err = ::ICGetPref(icInstance, kICDownloadFolder, &attrs, &icFileSpec, &size);
if (err == noErr || (err == icTruncatedErr && size >= kICFileSpecHeaderSize)) if (err == noErr || (err == icTruncatedErr && size >= kICFileSpecHeaderSize))
{ {
@ -1210,12 +1212,12 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret
NS_RELEASE(inAtom); NS_RELEASE(inAtom);
if (localFile && NS_SUCCEEDED(rv)) if (localFile && NS_SUCCEEDED(rv))
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval); return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
#ifdef DEBUG_dougt #ifdef DEBUG_dougt
printf("Failed to find directory for key: %s\n", prop); printf("Failed to find directory for key: %s\n", prop);
#endif #endif
return rv; return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP