1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 var EXPORTED_SYMBOLS = ["CrashReports"];
11 getReports: function CrashReports_getReports() {
15 // Ignore any non http/https urls
16 if (!/^https?:/i.test(Services.prefs.getCharPref("breakpad.reportURL"))) {
21 if (this.submittedDir.exists() && this.submittedDir.isDirectory()) {
22 let entries = this.submittedDir.directoryEntries;
23 while (entries.hasMoreElements()) {
24 let file = entries.nextFile;
25 let leaf = file.leafName;
26 if (leaf.startsWith("bp-") && leaf.endsWith(".txt")) {
28 id: leaf.slice(0, -4),
29 date: file.lastModifiedTime,
37 if (this.pendingDir.exists() && this.pendingDir.isDirectory()) {
38 let uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
39 let entries = this.pendingDir.directoryEntries;
40 while (entries.hasMoreElements()) {
41 let file = entries.nextFile;
42 let leaf = file.leafName;
43 let id = leaf.slice(0, -4);
44 if (leaf.endsWith(".dmp") && uuidRegex.test(id)) {
47 date: file.lastModifiedTime,
55 // Sort reports descending by date
56 return reports.sort((a, b) => b.date - a.date);
60 function CrashReports_pendingDir() {
61 let pendingDir = Services.dirsvc.get("UAppData", Ci.nsIFile);
62 pendingDir.append("Crash Reports");
63 pendingDir.append("pending");
67 function CrashReports_reportsDir() {
68 let reportsDir = Services.dirsvc.get("UAppData", Ci.nsIFile);
69 reportsDir.append("Crash Reports");
73 function CrashReports_submittedDir() {
74 let submittedDir = Services.dirsvc.get("UAppData", Ci.nsIFile);
75 submittedDir.append("Crash Reports");
76 submittedDir.append("submitted");
80 CrashReports.pendingDir = CrashReports_pendingDir();
81 CrashReports.reportsDir = CrashReports_reportsDir();
82 CrashReports.submittedDir = CrashReports_submittedDir();