Bug 1063126 - DeviceStorage - Add some logging. r=khuey

This commit is contained in:
Dave Hylands 2014-09-05 15:41:01 -07:00
parent 72ffa9c717
commit a005dd1fc0

View File

@ -871,13 +871,17 @@ DeviceStorageFile::GetRootDirectoryForType(const nsAString& aStorageType,
InitDirs();
#ifdef MOZ_WIDGET_GONK
nsresult rv;
nsString volMountPoint;
if (DeviceStorageTypeChecker::IsVolumeBased(aStorageType)) {
nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(vs);
nsresult rv;
nsCOMPtr<nsIVolume> vol;
rv = vs->GetVolumeByName(aStorageName, getter_AddRefs(vol));
if(NS_FAILED(rv)) {
printf_stderr("##### DeviceStorage: GetVolumeByName('%s') failed\n",
NS_LossyConvertUTF16toASCII(aStorageName).get());
}
NS_ENSURE_SUCCESS_VOID(rv);
vol->GetMountPoint(volMountPoint);
}
@ -886,7 +890,12 @@ DeviceStorageFile::GetRootDirectoryForType(const nsAString& aStorageType,
// Picture directory
if (aStorageType.EqualsLiteral(DEVICESTORAGE_PICTURES)) {
#ifdef MOZ_WIDGET_GONK
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
rv = NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
if(NS_FAILED(rv)) {
printf_stderr("##### DeviceStorage: NS_NewLocalFile failed StorageType: '%s' path '%s'\n",
NS_LossyConvertUTF16toASCII(volMountPoint).get(),
NS_LossyConvertUTF16toASCII(aStorageType).get());
}
#else
f = sDirs->pictures;
#endif
@ -895,7 +904,12 @@ DeviceStorageFile::GetRootDirectoryForType(const nsAString& aStorageType,
// Video directory
else if (aStorageType.EqualsLiteral(DEVICESTORAGE_VIDEOS)) {
#ifdef MOZ_WIDGET_GONK
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
rv = NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
if(NS_FAILED(rv)) {
printf_stderr("##### DeviceStorage: NS_NewLocalFile failed StorageType: '%s' path '%s'\n",
NS_LossyConvertUTF16toASCII(volMountPoint).get(),
NS_LossyConvertUTF16toASCII(aStorageType).get());
}
#else
f = sDirs->videos;
#endif
@ -904,7 +918,12 @@ DeviceStorageFile::GetRootDirectoryForType(const nsAString& aStorageType,
// Music directory
else if (aStorageType.EqualsLiteral(DEVICESTORAGE_MUSIC)) {
#ifdef MOZ_WIDGET_GONK
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
rv = NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
if(NS_FAILED(rv)) {
printf_stderr("##### DeviceStorage: NS_NewLocalFile failed StorageType: '%s' path '%s'\n",
NS_LossyConvertUTF16toASCII(volMountPoint).get(),
NS_LossyConvertUTF16toASCII(aStorageType).get());
}
#else
f = sDirs->music;
#endif
@ -919,7 +938,12 @@ DeviceStorageFile::GetRootDirectoryForType(const nsAString& aStorageType,
// default SDCard
else if (aStorageType.EqualsLiteral(DEVICESTORAGE_SDCARD)) {
#ifdef MOZ_WIDGET_GONK
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
rv = NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
if(NS_FAILED(rv)) {
printf_stderr("##### DeviceStorage: NS_NewLocalFile failed StorageType: '%s' path '%s'\n",
NS_LossyConvertUTF16toASCII(volMountPoint).get(),
NS_LossyConvertUTF16toASCII(aStorageType).get());
}
#else
f = sDirs->sdcard;
#endif
@ -945,6 +969,12 @@ DeviceStorageFile::GetRootDirectoryForType(const nsAString& aStorageType,
if (f) {
f->Clone(aFile);
} else {
// This should never happen unless something is severely wrong. So
// scream a little.
printf_stderr("##### GetRootDirectoryForType('%s', '%s') failed #####",
NS_LossyConvertUTF16toASCII(aStorageType).get(),
NS_LossyConvertUTF16toASCII(aStorageName).get());
}
}