mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 961369 - Fallback when no file picker available in about:memory. r=njn,mfinkle
This commit is contained in:
parent
7c36268390
commit
98314fbfff
@ -25,6 +25,7 @@ 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/@ANDROID_PACKAGE_NAME@/distribution";
|
||||
|
||||
@ -73,6 +74,9 @@ DirectoryProvider.prototype = {
|
||||
}
|
||||
let dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
|
||||
return dm.defaultDownloadsDirectory;
|
||||
} else if (prop == DOWNLOAD_DIR) {
|
||||
let dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
|
||||
return dm.defaultDownloadsDirectory;
|
||||
}
|
||||
|
||||
// We are retuning null to show failure instead for throwing an error. The
|
||||
|
@ -23,6 +23,7 @@ FilePicker.prototype = {
|
||||
_filePath: null,
|
||||
_promptActive: false,
|
||||
_filterIndex: 0,
|
||||
_addToRecentDocs: false,
|
||||
|
||||
init: function(aParent, aTitle, aMode) {
|
||||
this._domWin = aParent;
|
||||
@ -150,11 +151,11 @@ FilePicker.prototype = {
|
||||
},
|
||||
|
||||
get addToRecentDocs() {
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
return this._addToRecentDocs;
|
||||
},
|
||||
|
||||
set addToRecentDocs(val) {
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
this._addToRecentDocs = val;
|
||||
},
|
||||
|
||||
get mode() {
|
||||
|
@ -1844,26 +1844,39 @@ function appendSectionHeader(aP, aText)
|
||||
function saveReportsToFile()
|
||||
{
|
||||
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
|
||||
fp.init(window, "Save Memory Reports", Ci.nsIFilePicker.modeSave);
|
||||
fp.appendFilter("Zipped JSON files", "*.json.gz");
|
||||
fp.appendFilters(Ci.nsIFilePicker.filterAll);
|
||||
fp.filterIndex = 0;
|
||||
fp.addToRecentDocs = true;
|
||||
fp.defaultString = "memory-report.json.gz";
|
||||
|
||||
let fpFinish = function(file) {
|
||||
let dumper = Cc["@mozilla.org/memory-info-dumper;1"]
|
||||
.getService(Ci.nsIMemoryInfoDumper);
|
||||
|
||||
let finishDumping = () => {
|
||||
updateMainAndFooter("Saved reports to " + file.path, HIDE_FOOTER);
|
||||
}
|
||||
|
||||
dumper.dumpMemoryReportsToNamedFile(file.path, finishDumping, null);
|
||||
}
|
||||
|
||||
let fpCallback = function(aResult) {
|
||||
if (aResult == Ci.nsIFilePicker.returnOK ||
|
||||
aResult == Ci.nsIFilePicker.returnReplace) {
|
||||
|
||||
let dumper = Cc["@mozilla.org/memory-info-dumper;1"]
|
||||
.getService(Ci.nsIMemoryInfoDumper);
|
||||
|
||||
let finishDumping = () => {
|
||||
updateMainAndFooter("Saved reports to " + fp.file.path, HIDE_FOOTER);
|
||||
}
|
||||
|
||||
dumper.dumpMemoryReportsToNamedFile(fp.file.path, finishDumping, null);
|
||||
fpFinish(fp.file);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
fp.init(window, "Save Memory Reports", Ci.nsIFilePicker.modeSave);
|
||||
} 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);
|
||||
return;
|
||||
}
|
||||
fp.open(fpCallback);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user