Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 814086 - Limit the size of the pending queue of crash reports to …
Browse files Browse the repository at this point in the history
…10. r=bsmedberg
  • Loading branch information
hfiguiere committed Dec 11, 2012
1 parent c7bddf1 commit 0b07296
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
5 changes: 4 additions & 1 deletion b2g/chrome/content/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ var shell = {
return;
}

// purge the queue.
this.CrashSubmit.pruneSavedDumps();

try {
// Check if we should automatically submit this crash.
if (Services.prefs.getBoolPref("app.reportCrashes")) {
Expand Down Expand Up @@ -135,7 +138,7 @@ var shell = {
&& network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
shell.CrashSubmit.submit(aCrashID);

// purge the queue.
// submit the pending queue.
let pending = shell.CrashSubmit.pendingIDs();
for (let crashid of pending) {
shell.CrashSubmit.submit(crashid);
Expand Down
50 changes: 49 additions & 1 deletion toolkit/crashreporter/CrashSubmit.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ function getAllPendingMinidumpsIDs() {
while (entries.hasMoreElements()) {
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
if (entry.isFile()) {
entry.leafName
let matches = entry.leafName.match(/(.+)\.extra$/);
if (matches)
minidumps.push(matches[1]);
Expand All @@ -110,6 +109,48 @@ function getAllPendingMinidumpsIDs() {
return minidumps;
}

function pruneSavedDumps() {
const KEEP = 10;

let pendingDir = getPendingDir();
if (!(pendingDir.exists() && pendingDir.isDirectory()))
return;
let entries = pendingDir.directoryEntries;
let entriesArray = [];

while (entries.hasMoreElements()) {
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
if (entry.isFile()) {
let matches = entry.leafName.match(/(.+)\.extra$/);
if (matches)
entriesArray.push(entry);
}
}

entriesArray.sort(function(a,b) {
let dateA = a.lastModifiedTime;
let dateB = b.lastModifiedTime;
if (dateA < dateB)
return -1;
if (dateB < dateA)
return 1;
return 0;
});

if (entriesArray.length > KEEP) {
for (let i = 0; i < entriesArray.length - KEEP; ++i) {
let extra = entriesArray[i];
let matches = extra.leafName.match(/(.+)\.extra$/);
if (matches) {
let dump = extra.clone();
dump.leafName = matches[1] + '.dmp';
dump.remove(false);
extra.remove(false);
}
}
}
}

function addFormEntry(doc, form, name, value) {
var input = doc.createElement("input");
input.type = "hidden";
Expand Down Expand Up @@ -387,6 +428,13 @@ this.CrashSubmit = {
return getAllPendingMinidumpsIDs();
},

/**
* Prune the saved dumps.
*/
pruneSavedDumps: function CrashSubmit_pruneSavedDumps() {
pruneSavedDumps();
},

// List of currently active submit objects
_activeSubmissions: []
};
Expand Down

0 comments on commit 0b07296

Please sign in to comment.