Bug 1024672 - Part 5: Allow classifications to be stored in crash metadata. r=gps

This commit is contained in:
Birunthan Mohanathas 2014-09-02 09:55:16 -07:00
parent 1d1b22bce6
commit f2221e65ab
3 changed files with 53 additions and 0 deletions

View File

@ -419,6 +419,21 @@ this.CrashManager.prototype = Object.freeze({
}
}),
/**
* Set the classification of a crash.
*
* @param crashID (string) Crash ID. Likely a UUID.
* @param classification (string) Crash classification/reason.
*
* @return boolean True if the classification was recorded and false if not.
*/
setCrashClassification: Task.async(function* (crashID, classification) {
let store = yield this._getStore();
if (store.setCrashClassification(crashID, classification)) {
yield store.save();
}
}),
/**
* Obtain the paths of all unprocessed events files.
*
@ -1062,6 +1077,7 @@ CrashStore.prototype = Object.freeze({
type: type,
crashDate: date,
submissions: new Map(),
classification: null,
});
}
@ -1170,6 +1186,19 @@ CrashStore.prototype = Object.freeze({
submission.result = result;
return true;
},
/**
* @return boolean True if the classification was set.
*/
setCrashClassification: function (crashID, classification) {
let crash = this._data.crashes.get(crashID);
if (!crash) {
return false;
}
crash.classification = classification;
return true;
},
});
/**
@ -1227,6 +1256,10 @@ CrashRecord.prototype = Object.freeze({
get submissions() {
return this._o.submissions;
},
get classification() {
return this._o.classification;
},
});
/**

View File

@ -396,6 +396,15 @@ add_task(function* test_addSubmissionAttemptAndResult() {
Assert.equal(submission.result, m.SUBMISSION_RESULT_OK);
});
add_task(function* test_setCrashClassification() {
let m = yield getManager();
yield m.addCrash(m.PROCESS_TYPE_MAIN, m.CRASH_TYPE_CRASH,
"main-crash", DUMMY_DATE);
yield m.setCrashClassification("main-crash", "class");
Assert.equal((yield m.getCrashes())[0].classification, "class");
});
add_task(function* test_setRemoteCrashID() {
let m = yield getManager();

View File

@ -566,6 +566,17 @@ add_task(function* test_convertSubmissionsStoredAsCrashes() {
Assert.equal(submission.responseDate.getTime(), DUMMY_DATE_2.getTime());
});
add_task(function* test_setCrashClassification() {
let s = yield getStore();
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "crash1",
new Date()));
Assert.equal(s.crashes[0].classification, null);
Assert.ok(s.setCrashClassification("crash1", "foo"));
Assert.equal(s.crashes[0].classification, "foo");
});
add_task(function* test_setRemoteCrashID() {
let s = yield getStore();