Bug 1135543 - Part 2 (no part 1): Add a |metadata| parameter to CrashManager.addCrash(); r=bsmedberg

--HG--
extra : rebase_source : a0a4c06fb530eebfdf690d170c819b67375bd5b7
This commit is contained in:
David Major 2015-03-14 18:54:06 +13:00
Родитель 223470bfe4
Коммит 5de2cde13f
2 изменённых файлов: 22 добавлений и 6 удалений

Просмотреть файл

@ -359,13 +359,14 @@ this.CrashManager.prototype = Object.freeze({
* @param crashType (string) One of the CRASH_TYPE constants.
* @param id (string) Crash ID. Likely a UUID.
* @param date (Date) When the crash occurred.
* @param metadata (dictionary) Crash metadata, may be empty.
*
* @return promise<null> Resolved when the store has been saved.
*/
addCrash: function (processType, crashType, id, date) {
addCrash: function (processType, crashType, id, date, metadata) {
return Task.spawn(function* () {
let store = yield this._getStore();
if (store.addCrash(processType, crashType, id, date)) {
if (store.addCrash(processType, crashType, id, date, metadata)) {
yield store.save();
}
}.bind(this));
@ -1052,10 +1053,12 @@ CrashStore.prototype = Object.freeze({
* (string) The crash ID.
* @param date
* (Date) When this crash occurred.
* @param metadata
* (dictionary) Crash metadata, may be empty.
*
* @return null | object crash record
*/
_ensureCrashRecord: function (processType, crashType, id, date) {
_ensureCrashRecord: function (processType, crashType, id, date, metadata) {
if (!id) {
// Crashes are keyed on ID, so it's not really helpful to store crashes
// without IDs.
@ -1083,6 +1086,7 @@ CrashStore.prototype = Object.freeze({
crashDate: date,
submissions: new Map(),
classifications: [],
metadata: metadata,
});
}
@ -1100,11 +1104,12 @@ CrashStore.prototype = Object.freeze({
* @param crashType (string) One of the CRASH_TYPE constants.
* @param id (string) Crash ID. Likely a UUID.
* @param date (Date) When the crash occurred.
* @param metadata (dictionary) Crash metadata, may be empty.
*
* @return boolean True if the crash was recorded and false if not.
*/
addCrash: function (processType, crashType, id, date) {
return !!this._ensureCrashRecord(processType, crashType, id, date);
addCrash: function (processType, crashType, id, date, metadata) {
return !!this._ensureCrashRecord(processType, crashType, id, date, metadata);
},
/**
@ -1265,6 +1270,10 @@ CrashRecord.prototype = Object.freeze({
get classifications() {
return this._o.classifications;
},
get metadata() {
return this._o.metadata;
},
});
/**

Просмотреть файл

@ -161,8 +161,15 @@ add_task(function* test_add_main_crash() {
);
Assert.equal(s.crashesCount, 2);
Assert.ok(
s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id3", new Date(),
{ OOMAllocationSize: 1048576 })
);
Assert.equal(s.crashesCount, 3);
Assert.deepEqual(s.crashes[2].metadata, { OOMAllocationSize: 1048576 });
let crashes = s.getCrashesOfType(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH);
Assert.equal(crashes.length, 2);
Assert.equal(crashes.length, 3);
});
add_task(function* test_add_main_hang() {