Bug 1115006 - Use Downloads.getSystemDownloadsDirectory to get download directory for about:memory on Fennec. r=mconley,margaret

MozReview-Commit-ID: JBod1Ltcz0w

--HG--
extra : rebase_source : 3fdf3b1160f36b77c10641cab4e056c2a77dc151
This commit is contained in:
Rutuja 2016-04-19 10:39:12 -04:00
Родитель 6622dc6117
Коммит 6b35519b8f
2 изменённых файлов: 10 добавлений и 10 удалений

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

@ -27,7 +27,6 @@ const XRE_APP_DISTRIBUTION_DIR = "XREAppDist";
const XRE_UPDATE_ROOT_DIR = "UpdRootD";
const ENVVAR_UPDATE_DIR = "UPDATES_DIRECTORY";
const WEBAPPS_DIR = "webappsDir";
const DOWNLOAD_DIR = "DfltDwnld";
const SYSTEM_DIST_PATH = `/system/${AppConstants.ANDROID_PACKAGE_NAME}/distribution`;
@ -69,12 +68,6 @@ DirectoryProvider.prototype = {
}
}
return new FileUtils.File(env.get("DOWNLOADS_DIRECTORY"));
} else if (prop == DOWNLOAD_DIR) {
// Downloads.getSystemDownloadsDirectory is asynchronous, but getFile is
// synchronous, so just return what the getSystemDownloadsDirectory
// implementation would have returned.
let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
return new FileUtils.File(env.get("DOWNLOADS_DIRECTORY"));
}
// We are retuning null to show failure instead for throwing an error. The

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

@ -35,6 +35,10 @@ const UNITS_PERCENTAGE = Ci.nsIMemoryReporter.UNITS_PERCENTAGE;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
"resource://gre/modules/Downloads.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "nsBinaryStream",
() => CC("@mozilla.org/binaryinputstream;1",
@ -2026,9 +2030,12 @@ function saveReportsToFile()
} catch(ex) {
// This will fail on Android, since there is no Save as file picker there.
// Just save to the default downloads dir if it does.
let file = Services.dirsvc.get("DfltDwnld", Ci.nsIFile);
file.append(fp.defaultString);
fpFinish(file);
Downloads.getSystemDownloadsDirectory().then(function(dirPath) {
let file = FileUtils.File(dirPath);
file.append(fp.defaultString);
fpFinish(file);
});
return;
}
fp.open(fpCallback);