2013-10-28 03:18:14 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2019-01-17 21:18:31 +03:00
|
|
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
2013-10-28 03:18:14 +04:00
|
|
|
|
2018-02-23 22:50:01 +03:00
|
|
|
var EXPORTED_SYMBOLS = ["CrashReports"];
|
2013-10-28 03:18:14 +04:00
|
|
|
|
2018-02-23 22:50:01 +03:00
|
|
|
var CrashReports = {
|
2013-10-28 03:18:14 +04:00
|
|
|
pendingDir: null,
|
|
|
|
reportsDir: null,
|
|
|
|
submittedDir: null,
|
2016-12-31 05:47:25 +03:00
|
|
|
getReports: function CrashReports_getReports() {
|
2013-10-28 03:18:14 +04:00
|
|
|
let reports = [];
|
|
|
|
|
|
|
|
try {
|
|
|
|
// Ignore any non http/https urls
|
|
|
|
if (!/^https?:/i.test(Services.prefs.getCharPref("breakpad.reportURL"))) {
|
|
|
|
return reports;
|
2016-12-31 05:47:25 +03:00
|
|
|
}
|
|
|
|
} catch (e) {}
|
2013-10-28 03:18:14 +04:00
|
|
|
|
|
|
|
if (this.submittedDir.exists() && this.submittedDir.isDirectory()) {
|
|
|
|
let entries = this.submittedDir.directoryEntries;
|
|
|
|
while (entries.hasMoreElements()) {
|
2018-05-20 06:17:45 +03:00
|
|
|
let file = entries.nextFile;
|
2013-10-28 03:18:14 +04:00
|
|
|
let leaf = file.leafName;
|
|
|
|
if (leaf.startsWith("bp-") && leaf.endsWith(".txt")) {
|
|
|
|
let entry = {
|
|
|
|
id: leaf.slice(0, -4),
|
|
|
|
date: file.lastModifiedTime,
|
2018-08-31 08:59:17 +03:00
|
|
|
pending: false,
|
2013-10-28 03:18:14 +04:00
|
|
|
};
|
|
|
|
reports.push(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.pendingDir.exists() && this.pendingDir.isDirectory()) {
|
|
|
|
let uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
|
|
let entries = this.pendingDir.directoryEntries;
|
|
|
|
while (entries.hasMoreElements()) {
|
2018-05-20 06:17:45 +03:00
|
|
|
let file = entries.nextFile;
|
2013-10-28 03:18:14 +04:00
|
|
|
let leaf = file.leafName;
|
|
|
|
let id = leaf.slice(0, -4);
|
|
|
|
if (leaf.endsWith(".dmp") && uuidRegex.test(id)) {
|
|
|
|
let entry = {
|
2016-12-30 02:34:54 +03:00
|
|
|
id,
|
2013-10-28 03:18:14 +04:00
|
|
|
date: file.lastModifiedTime,
|
2018-08-31 08:59:17 +03:00
|
|
|
pending: true,
|
2013-10-28 03:18:14 +04:00
|
|
|
};
|
|
|
|
reports.push(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort reports descending by date
|
|
|
|
return reports.sort((a, b) => b.date - a.date);
|
2018-08-31 08:59:17 +03:00
|
|
|
},
|
2017-10-15 21:50:30 +03:00
|
|
|
};
|
2013-10-28 03:18:14 +04:00
|
|
|
|
2016-12-31 05:47:25 +03:00
|
|
|
function CrashReports_pendingDir() {
|
2018-02-28 20:51:33 +03:00
|
|
|
let pendingDir = Services.dirsvc.get("UAppData", Ci.nsIFile);
|
2013-10-28 03:18:14 +04:00
|
|
|
pendingDir.append("Crash Reports");
|
|
|
|
pendingDir.append("pending");
|
|
|
|
return pendingDir;
|
|
|
|
}
|
|
|
|
|
2016-12-31 05:47:25 +03:00
|
|
|
function CrashReports_reportsDir() {
|
2018-02-28 20:51:33 +03:00
|
|
|
let reportsDir = Services.dirsvc.get("UAppData", Ci.nsIFile);
|
2013-10-28 03:18:14 +04:00
|
|
|
reportsDir.append("Crash Reports");
|
|
|
|
return reportsDir;
|
|
|
|
}
|
|
|
|
|
2016-12-31 05:47:25 +03:00
|
|
|
function CrashReports_submittedDir() {
|
2018-02-28 20:51:33 +03:00
|
|
|
let submittedDir = Services.dirsvc.get("UAppData", Ci.nsIFile);
|
2013-10-28 03:18:14 +04:00
|
|
|
submittedDir.append("Crash Reports");
|
|
|
|
submittedDir.append("submitted");
|
|
|
|
return submittedDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.CrashReports.pendingDir = CrashReports_pendingDir();
|
|
|
|
this.CrashReports.reportsDir = CrashReports_reportsDir();
|
|
|
|
this.CrashReports.submittedDir = CrashReports_submittedDir();
|