2012-05-21 04:12:37 -07: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/. */
|
2010-02-09 17:05:31 -08:00
|
|
|
|
2010-03-16 22:10:08 -07:00
|
|
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
2012-09-08 10:20:59 -07:00
|
|
|
Components.utils.import("resource://gre/modules/KeyValueParser.jsm");
|
2014-10-08 09:15:22 -07:00
|
|
|
Components.utils.importGlobalProperties(['File']);
|
2010-03-16 22:10:08 -07:00
|
|
|
|
2012-10-31 09:13:28 -07:00
|
|
|
this.EXPORTED_SYMBOLS = [
|
2010-02-09 17:05:31 -08:00
|
|
|
"CrashSubmit"
|
|
|
|
];
|
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const STATE_START = Ci.nsIWebProgressListener.STATE_START;
|
|
|
|
const STATE_STOP = Ci.nsIWebProgressListener.STATE_STOP;
|
|
|
|
|
2010-03-16 22:10:08 -07:00
|
|
|
const SUCCESS = "success";
|
|
|
|
const FAILED = "failed";
|
|
|
|
const SUBMITTING = "submitting";
|
|
|
|
|
2010-02-09 17:05:31 -08:00
|
|
|
let reportURL = null;
|
|
|
|
let strings = null;
|
|
|
|
let myListener = null;
|
|
|
|
|
|
|
|
function parseINIStrings(file) {
|
|
|
|
var factory = Cc["@mozilla.org/xpcom/ini-parser-factory;1"].
|
|
|
|
getService(Ci.nsIINIParserFactory);
|
|
|
|
var parser = factory.createINIParser(file);
|
|
|
|
var obj = {};
|
|
|
|
var en = parser.getKeys("Strings");
|
|
|
|
while (en.hasMore()) {
|
|
|
|
var key = en.getNext();
|
|
|
|
obj[key] = parser.getString("Strings", key);
|
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Since we're basically re-implementing part of the crashreporter
|
|
|
|
// client here, we'll just steal the strings we need from crashreporter.ini
|
|
|
|
function getL10nStrings() {
|
|
|
|
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
|
|
|
getService(Ci.nsIProperties);
|
|
|
|
let path = dirSvc.get("GreD", Ci.nsIFile);
|
|
|
|
path.append("crashreporter.ini");
|
|
|
|
if (!path.exists()) {
|
|
|
|
// see if we're on a mac
|
|
|
|
path = path.parent;
|
2014-09-29 11:51:13 -07:00
|
|
|
path = path.parent;
|
|
|
|
path.append("MacOS");
|
2010-02-09 17:05:31 -08:00
|
|
|
path.append("crashreporter.app");
|
|
|
|
path.append("Contents");
|
2014-09-29 11:51:13 -07:00
|
|
|
path.append("Resources");
|
2010-02-09 17:05:31 -08:00
|
|
|
path.append("crashreporter.ini");
|
|
|
|
if (!path.exists()) {
|
|
|
|
// very bad, but I don't know how to recover
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let crstrings = parseINIStrings(path);
|
|
|
|
strings = {
|
|
|
|
'crashid': crstrings.CrashID,
|
|
|
|
'reporturl': crstrings.CrashDetailsURL
|
|
|
|
};
|
|
|
|
|
|
|
|
path = dirSvc.get("XCurProcD", Ci.nsIFile);
|
|
|
|
path.append("crashreporter-override.ini");
|
|
|
|
if (path.exists()) {
|
|
|
|
crstrings = parseINIStrings(path);
|
|
|
|
if ('CrashID' in crstrings)
|
|
|
|
strings['crashid'] = crstrings.CrashID;
|
|
|
|
if ('CrashDetailsURL' in crstrings)
|
|
|
|
strings['reporturl'] = crstrings.CrashDetailsURL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-20 08:31:29 -07:00
|
|
|
function getDir(name) {
|
2010-02-09 17:05:31 -08:00
|
|
|
let directoryService = Cc["@mozilla.org/file/directory_service;1"].
|
|
|
|
getService(Ci.nsIProperties);
|
2014-06-20 08:31:29 -07:00
|
|
|
let dir = directoryService.get("UAppData", Ci.nsIFile);
|
|
|
|
dir.append("Crash Reports");
|
|
|
|
dir.append(name);
|
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
function writeFile(dirName, fileName, data) {
|
|
|
|
let path = getDir(dirName);
|
|
|
|
if (!path.exists())
|
|
|
|
path.create(Ci.nsIFile.DIRECTORY_TYPE, 0700);
|
|
|
|
path.append(fileName);
|
|
|
|
var fs = Cc["@mozilla.org/network/file-output-stream;1"].
|
|
|
|
createInstance(Ci.nsIFileOutputStream);
|
|
|
|
// open, write, truncate
|
|
|
|
fs.init(path, -1, -1, 0);
|
|
|
|
var os = Cc["@mozilla.org/intl/converter-output-stream;1"].
|
|
|
|
createInstance(Ci.nsIConverterOutputStream);
|
|
|
|
os.init(fs, "UTF-8", 0, 0x0000);
|
|
|
|
os.writeString(data);
|
|
|
|
os.close();
|
|
|
|
fs.close();
|
2012-12-06 13:27:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function getPendingMinidump(id) {
|
2014-06-20 08:31:29 -07:00
|
|
|
let pendingDir = getDir("pending");
|
2010-02-09 17:05:31 -08:00
|
|
|
let dump = pendingDir.clone();
|
|
|
|
let extra = pendingDir.clone();
|
2014-08-29 22:21:25 -07:00
|
|
|
let memory = pendingDir.clone();
|
2010-02-09 17:05:31 -08:00
|
|
|
dump.append(id + ".dmp");
|
|
|
|
extra.append(id + ".extra");
|
2014-08-29 22:21:25 -07:00
|
|
|
memory.append(id + ".memory.json.gz");
|
|
|
|
return [dump, extra, memory];
|
2010-02-09 17:05:31 -08:00
|
|
|
}
|
|
|
|
|
2012-12-06 13:27:49 -08:00
|
|
|
function getAllPendingMinidumpsIDs() {
|
|
|
|
let minidumps = [];
|
2014-06-20 08:31:29 -07:00
|
|
|
let pendingDir = getDir("pending");
|
2012-12-06 13:27:49 -08:00
|
|
|
|
|
|
|
if (!(pendingDir.exists() && pendingDir.isDirectory()))
|
|
|
|
return [];
|
|
|
|
let entries = pendingDir.directoryEntries;
|
|
|
|
|
|
|
|
while (entries.hasMoreElements()) {
|
|
|
|
let entry = entries.getNext().QueryInterface(Ci.nsIFile);
|
|
|
|
if (entry.isFile()) {
|
|
|
|
let matches = entry.leafName.match(/(.+)\.extra$/);
|
|
|
|
if (matches)
|
|
|
|
minidumps.push(matches[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return minidumps;
|
|
|
|
}
|
|
|
|
|
2012-12-11 14:06:48 -08:00
|
|
|
function pruneSavedDumps() {
|
|
|
|
const KEEP = 10;
|
|
|
|
|
2014-06-20 08:31:29 -07:00
|
|
|
let pendingDir = getDir("pending");
|
2012-12-11 14:06:48 -08:00
|
|
|
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)
|
2014-06-20 08:31:29 -07:00
|
|
|
entriesArray.push(entry);
|
2012-12-11 14:06:48 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2014-08-29 22:21:25 -07:00
|
|
|
|
|
|
|
let memory = extra.clone();
|
|
|
|
memory.leafName = matches[1] + '.memory.json.gz';
|
|
|
|
if (memory.exists()) {
|
|
|
|
memory.remove(false);
|
|
|
|
}
|
|
|
|
|
2012-12-11 14:06:48 -08:00
|
|
|
extra.remove(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-09 17:05:31 -08:00
|
|
|
function addFormEntry(doc, form, name, value) {
|
|
|
|
var input = doc.createElement("input");
|
|
|
|
input.type = "hidden";
|
|
|
|
input.name = name;
|
|
|
|
input.value = value;
|
|
|
|
form.appendChild(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
function writeSubmittedReport(crashID, viewURL) {
|
|
|
|
var data = strings.crashid.replace("%s", crashID);
|
|
|
|
if (viewURL)
|
|
|
|
data += "\n" + strings.reporturl.replace("%s", viewURL);
|
|
|
|
|
2014-06-20 08:31:29 -07:00
|
|
|
writeFile("submitted", crashID + ".txt", data);
|
2010-02-09 17:05:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// the Submitter class represents an individual submission.
|
2014-08-21 15:43:50 -07:00
|
|
|
function Submitter(id, recordSubmission, submitSuccess, submitError,
|
|
|
|
noThrottle, extraExtraKeyVals) {
|
2010-02-09 17:05:31 -08:00
|
|
|
this.id = id;
|
2014-08-21 15:43:50 -07:00
|
|
|
this.recordSubmission = recordSubmission;
|
2010-02-09 17:05:31 -08:00
|
|
|
this.successCallback = submitSuccess;
|
|
|
|
this.errorCallback = submitError;
|
2010-06-30 07:29:05 -07:00
|
|
|
this.noThrottle = noThrottle;
|
2012-09-08 10:20:59 -07:00
|
|
|
this.additionalDumps = [];
|
2013-02-14 15:57:50 -08:00
|
|
|
this.extraKeyVals = extraExtraKeyVals || {};
|
2010-02-09 17:05:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Submitter.prototype = {
|
|
|
|
submitSuccess: function Submitter_submitSuccess(ret)
|
|
|
|
{
|
|
|
|
// Write out the details file to submitted/
|
|
|
|
writeSubmittedReport(ret.CrashID, ret.ViewURL);
|
|
|
|
|
|
|
|
// Delete from pending dir
|
|
|
|
try {
|
|
|
|
this.dump.remove(false);
|
|
|
|
this.extra.remove(false);
|
2014-08-29 22:21:25 -07:00
|
|
|
|
|
|
|
if (this.memory) {
|
|
|
|
this.memory.remove(false);
|
|
|
|
}
|
|
|
|
|
2012-09-08 10:20:59 -07:00
|
|
|
for (let i of this.additionalDumps) {
|
|
|
|
i.dump.remove(false);
|
|
|
|
}
|
2010-02-09 17:05:31 -08:00
|
|
|
}
|
|
|
|
catch (ex) {
|
|
|
|
// report an error? not much the user can do here.
|
|
|
|
}
|
|
|
|
|
2010-03-16 22:10:08 -07:00
|
|
|
this.notifyStatus(SUCCESS, ret);
|
2010-02-09 17:05:31 -08:00
|
|
|
this.cleanup();
|
|
|
|
},
|
|
|
|
|
|
|
|
cleanup: function Submitter_cleanup() {
|
|
|
|
// drop some references just to be nice
|
|
|
|
this.successCallback = null;
|
|
|
|
this.errorCallback = null;
|
|
|
|
this.iframe = null;
|
|
|
|
this.dump = null;
|
|
|
|
this.extra = null;
|
2014-08-29 22:21:25 -07:00
|
|
|
this.memory = null;
|
2012-09-08 10:20:59 -07:00
|
|
|
this.additionalDumps = null;
|
2010-02-09 17:05:31 -08:00
|
|
|
// remove this object from the list of active submissions
|
|
|
|
let idx = CrashSubmit._activeSubmissions.indexOf(this);
|
|
|
|
if (idx != -1)
|
|
|
|
CrashSubmit._activeSubmissions.splice(idx, 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
submitForm: function Submitter_submitForm()
|
|
|
|
{
|
2013-02-14 15:57:50 -08:00
|
|
|
if (!('ServerURL' in this.extraKeyVals)) {
|
2010-02-09 17:05:31 -08:00
|
|
|
return false;
|
|
|
|
}
|
2013-02-14 15:57:50 -08:00
|
|
|
let serverURL = this.extraKeyVals.ServerURL;
|
2012-09-11 12:13:00 -07:00
|
|
|
|
2014-09-08 08:17:10 -07:00
|
|
|
// Override the submission URL from the environment
|
2012-09-11 12:13:00 -07:00
|
|
|
|
|
|
|
var envOverride = Cc['@mozilla.org/process/environment;1'].
|
|
|
|
getService(Ci.nsIEnvironment).get("MOZ_CRASHREPORTER_URL");
|
|
|
|
if (envOverride != '') {
|
|
|
|
serverURL = envOverride;
|
|
|
|
}
|
|
|
|
|
2011-07-20 17:51:55 -07:00
|
|
|
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
|
|
|
|
.createInstance(Ci.nsIXMLHttpRequest);
|
2012-09-11 12:13:00 -07:00
|
|
|
xhr.open("POST", serverURL, true);
|
2011-07-20 17:51:55 -07:00
|
|
|
|
|
|
|
let formData = Cc["@mozilla.org/files/formdata;1"]
|
|
|
|
.createInstance(Ci.nsIDOMFormData);
|
2013-02-14 15:57:50 -08:00
|
|
|
// add the data
|
|
|
|
for (let [name, value] in Iterator(this.extraKeyVals)) {
|
|
|
|
if (name != "ServerURL") {
|
|
|
|
formData.append(name, value);
|
|
|
|
}
|
2010-02-09 17:05:31 -08:00
|
|
|
}
|
2010-06-30 07:29:05 -07:00
|
|
|
if (this.noThrottle) {
|
|
|
|
// tell the server not to throttle this, since it was manually submitted
|
2011-07-20 17:51:55 -07:00
|
|
|
formData.append("Throttleable", "0");
|
2010-06-30 07:29:05 -07:00
|
|
|
}
|
2012-09-08 10:20:59 -07:00
|
|
|
// add the minidumps
|
2014-10-08 09:15:22 -07:00
|
|
|
formData.append("upload_file_minidump", new File(this.dump.path));
|
2014-08-29 22:21:25 -07:00
|
|
|
if (this.memory) {
|
2014-10-08 09:15:22 -07:00
|
|
|
formData.append("memory_report", new File(this.memory.path));
|
2014-08-29 22:21:25 -07:00
|
|
|
}
|
2012-09-08 10:20:59 -07:00
|
|
|
if (this.additionalDumps.length > 0) {
|
|
|
|
let names = [];
|
|
|
|
for (let i of this.additionalDumps) {
|
|
|
|
names.push(i.name);
|
|
|
|
formData.append("upload_file_minidump_"+i.name,
|
2014-10-08 09:15:22 -07:00
|
|
|
new File(i.dump.path));
|
2012-09-08 10:20:59 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-21 15:43:50 -07:00
|
|
|
let manager = Services.crashmanager;
|
2014-09-02 10:02:40 -07:00
|
|
|
let submissionID = manager.generateSubmissionID();
|
2014-08-21 15:43:50 -07:00
|
|
|
|
2011-07-20 17:51:55 -07:00
|
|
|
let self = this;
|
2011-09-29 09:06:36 -07:00
|
|
|
xhr.addEventListener("readystatechange", function (aEvt) {
|
2011-07-20 17:51:55 -07:00
|
|
|
if (xhr.readyState == 4) {
|
2014-07-09 08:14:42 -07:00
|
|
|
let ret =
|
|
|
|
xhr.status == 200 ? parseKeyValuePairs(xhr.responseText) : {};
|
|
|
|
let submitted = !!ret.CrashID;
|
|
|
|
|
2014-08-21 15:43:50 -07:00
|
|
|
if (self.recordSubmission) {
|
|
|
|
let result = submitted ? manager.SUBMISSION_RESULT_OK :
|
|
|
|
manager.SUBMISSION_RESULT_FAILED;
|
|
|
|
manager.addSubmissionResult(self.id, submissionID, new Date(),
|
|
|
|
result);
|
2014-08-28 21:03:02 -07:00
|
|
|
if (submitted) {
|
|
|
|
manager.setRemoteCrashID(self.id, ret.CrashID);
|
|
|
|
}
|
2014-07-09 08:14:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (submitted) {
|
2011-07-20 17:51:55 -07:00
|
|
|
self.submitSuccess(ret);
|
|
|
|
}
|
2014-07-09 08:14:42 -07:00
|
|
|
else {
|
|
|
|
self.notifyStatus(FAILED);
|
|
|
|
self.cleanup();
|
|
|
|
}
|
2010-02-09 17:05:31 -08:00
|
|
|
}
|
2011-09-29 09:06:36 -07:00
|
|
|
}, false);
|
2010-02-09 17:05:31 -08:00
|
|
|
|
2014-08-21 15:43:50 -07:00
|
|
|
if (this.recordSubmission) {
|
|
|
|
manager.addSubmissionAttempt(this.id, submissionID, new Date());
|
|
|
|
}
|
2011-07-20 17:51:55 -07:00
|
|
|
xhr.send(formData);
|
|
|
|
return true;
|
2010-02-09 17:05:31 -08:00
|
|
|
},
|
|
|
|
|
2010-03-16 22:10:08 -07:00
|
|
|
notifyStatus: function Submitter_notify(status, ret)
|
|
|
|
{
|
|
|
|
let propBag = Cc["@mozilla.org/hash-property-bag;1"].
|
|
|
|
createInstance(Ci.nsIWritablePropertyBag2);
|
|
|
|
propBag.setPropertyAsAString("minidumpID", this.id);
|
2010-06-30 07:29:05 -07:00
|
|
|
if (status == SUCCESS) {
|
|
|
|
propBag.setPropertyAsAString("serverCrashID", ret.CrashID);
|
|
|
|
}
|
2010-03-16 22:10:08 -07:00
|
|
|
|
2013-02-14 15:57:50 -08:00
|
|
|
let extraKeyValsBag = Cc["@mozilla.org/hash-property-bag;1"].
|
|
|
|
createInstance(Ci.nsIWritablePropertyBag2);
|
|
|
|
for (let key in this.extraKeyVals) {
|
|
|
|
extraKeyValsBag.setPropertyAsAString(key, this.extraKeyVals[key]);
|
|
|
|
}
|
|
|
|
propBag.setPropertyAsInterface("extra", extraKeyValsBag);
|
|
|
|
|
2010-03-16 22:10:08 -07:00
|
|
|
Services.obs.notifyObservers(propBag, "crash-report-status", status);
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case SUCCESS:
|
|
|
|
if (this.successCallback)
|
|
|
|
this.successCallback(this.id, ret);
|
|
|
|
break;
|
|
|
|
case FAILED:
|
|
|
|
if (this.errorCallback)
|
|
|
|
this.errorCallback(this.id);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// no callbacks invoked.
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-02-09 17:05:31 -08:00
|
|
|
submit: function Submitter_submit()
|
|
|
|
{
|
2014-08-29 22:21:25 -07:00
|
|
|
let [dump, extra, memory] = getPendingMinidump(this.id);
|
|
|
|
|
2010-02-10 09:20:37 -08:00
|
|
|
if (!dump.exists() || !extra.exists()) {
|
2010-03-16 22:10:08 -07:00
|
|
|
this.notifyStatus(FAILED);
|
2010-02-10 09:20:37 -08:00
|
|
|
this.cleanup();
|
2010-02-09 17:05:31 -08:00
|
|
|
return false;
|
2010-02-10 09:20:37 -08:00
|
|
|
}
|
2014-08-29 22:21:25 -07:00
|
|
|
this.dump = dump;
|
|
|
|
this.extra = extra;
|
|
|
|
|
|
|
|
// The memory file may or may not exist
|
|
|
|
if (memory.exists()) {
|
|
|
|
this.memory = memory;
|
|
|
|
}
|
2010-03-16 22:10:08 -07:00
|
|
|
|
2013-02-14 15:57:50 -08:00
|
|
|
let extraKeyVals = parseKeyValuePairsFromFile(extra);
|
|
|
|
for (let key in extraKeyVals) {
|
|
|
|
if (!(key in this.extraKeyVals)) {
|
|
|
|
this.extraKeyVals[key] = extraKeyVals[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-08 10:20:59 -07:00
|
|
|
let additionalDumps = [];
|
2013-02-14 15:57:50 -08:00
|
|
|
if ("additional_minidumps" in this.extraKeyVals) {
|
|
|
|
let names = this.extraKeyVals.additional_minidumps.split(',');
|
2012-09-14 13:37:58 -07:00
|
|
|
for (let name of names) {
|
2014-08-29 22:21:25 -07:00
|
|
|
let [dump, extra, memory] = getPendingMinidump(this.id + "-" + name);
|
2012-09-08 10:20:59 -07:00
|
|
|
if (!dump.exists()) {
|
|
|
|
this.notifyStatus(FAILED);
|
|
|
|
this.cleanup();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
additionalDumps.push({'name': name, 'dump': dump});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-16 22:10:08 -07:00
|
|
|
this.notifyStatus(SUBMITTING);
|
|
|
|
|
2012-09-08 10:20:59 -07:00
|
|
|
this.additionalDumps = additionalDumps;
|
2010-02-09 17:05:31 -08:00
|
|
|
|
2011-07-20 17:51:55 -07:00
|
|
|
if (!this.submitForm()) {
|
|
|
|
this.notifyStatus(FAILED);
|
|
|
|
this.cleanup();
|
|
|
|
return false;
|
2010-02-09 17:05:31 -08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//===================================
|
|
|
|
// External API goes here
|
2012-10-31 09:13:28 -07:00
|
|
|
this.CrashSubmit = {
|
2010-02-09 17:05:31 -08:00
|
|
|
/**
|
|
|
|
* Submit the crash report named id.dmp from the "pending" directory.
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* Filename (minus .dmp extension) of the minidump to submit.
|
2011-07-20 17:52:13 -07:00
|
|
|
* @param params
|
|
|
|
* An object containing any of the following optional parameters:
|
2014-08-21 15:43:50 -07:00
|
|
|
* - recordSubmission
|
|
|
|
* If true, a submission event is recorded in CrashManager.
|
2011-07-20 17:52:13 -07:00
|
|
|
* - submitSuccess
|
|
|
|
* A function that will be called if the report is submitted
|
|
|
|
* successfully with two parameters: the id that was passed
|
|
|
|
* to this function, and an object containing the key/value
|
|
|
|
* data returned from the server in its properties.
|
|
|
|
* - submitError
|
|
|
|
* A function that will be called with one parameter if the
|
|
|
|
* report fails to submit: the id that was passed to this
|
|
|
|
* function.
|
|
|
|
* - noThrottle
|
|
|
|
* If true, this crash report should be submitted with
|
|
|
|
* an extra parameter of "Throttleable=0" indicating that
|
|
|
|
* it should be processed right away. This should be set
|
|
|
|
* when the report is being submitted and the user expects
|
|
|
|
* to see the results immediately. Defaults to false.
|
2013-02-14 15:57:50 -08:00
|
|
|
* - extraExtraKeyVals
|
|
|
|
* An object whose key-value pairs will be merged with the data from
|
|
|
|
* the ".extra" file submitted with the report. The properties of
|
|
|
|
* this object will override properties of the same name in the
|
|
|
|
* .extra file.
|
2010-02-09 17:05:31 -08:00
|
|
|
*
|
|
|
|
* @return true if the submission began successfully, or false if
|
|
|
|
* it failed for some reason. (If the dump file does not
|
|
|
|
* exist, for example.)
|
|
|
|
*/
|
2011-07-20 17:52:13 -07:00
|
|
|
submit: function CrashSubmit_submit(id, params)
|
2010-02-09 17:05:31 -08:00
|
|
|
{
|
2011-07-20 17:52:13 -07:00
|
|
|
params = params || {};
|
2014-08-21 15:43:50 -07:00
|
|
|
let recordSubmission = false;
|
2011-07-20 17:52:13 -07:00
|
|
|
let submitSuccess = null;
|
|
|
|
let submitError = null;
|
|
|
|
let noThrottle = false;
|
2013-02-14 15:57:50 -08:00
|
|
|
let extraExtraKeyVals = null;
|
2011-07-20 17:52:13 -07:00
|
|
|
|
2014-08-21 15:43:50 -07:00
|
|
|
if ('recordSubmission' in params)
|
|
|
|
recordSubmission = params.recordSubmission;
|
2011-07-20 17:52:13 -07:00
|
|
|
if ('submitSuccess' in params)
|
|
|
|
submitSuccess = params.submitSuccess;
|
|
|
|
if ('submitError' in params)
|
|
|
|
submitError = params.submitError;
|
|
|
|
if ('noThrottle' in params)
|
|
|
|
noThrottle = params.noThrottle;
|
2013-02-14 15:57:50 -08:00
|
|
|
if ('extraExtraKeyVals' in params)
|
|
|
|
extraExtraKeyVals = params.extraExtraKeyVals;
|
2011-07-20 17:52:13 -07:00
|
|
|
|
2014-08-21 15:43:50 -07:00
|
|
|
let submitter = new Submitter(id, recordSubmission,
|
|
|
|
submitSuccess, submitError,
|
2014-07-09 08:14:42 -07:00
|
|
|
noThrottle, extraExtraKeyVals);
|
2010-02-09 17:05:31 -08:00
|
|
|
CrashSubmit._activeSubmissions.push(submitter);
|
|
|
|
return submitter.submit();
|
|
|
|
},
|
|
|
|
|
2013-05-02 09:57:41 -07:00
|
|
|
/**
|
|
|
|
* Delete the minidup from the "pending" directory.
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* Filename (minus .dmp extension) of the minidump to delete.
|
|
|
|
*/
|
|
|
|
delete: function CrashSubmit_delete(id) {
|
2014-08-29 22:21:25 -07:00
|
|
|
let [dump, extra, memory] = getPendingMinidump(id);
|
|
|
|
dump.remove(false);
|
|
|
|
extra.remove(false);
|
|
|
|
if (memory.exists()) {
|
|
|
|
memory.remove(false);
|
|
|
|
}
|
2013-05-02 09:57:41 -07:00
|
|
|
},
|
|
|
|
|
2012-12-06 13:27:49 -08:00
|
|
|
/**
|
|
|
|
* Get the list of pending crash IDs.
|
|
|
|
*
|
|
|
|
* @return an array of string, each being an ID as
|
|
|
|
* expected to be passed to submit()
|
|
|
|
*/
|
|
|
|
pendingIDs: function CrashSubmit_pendingIDs() {
|
|
|
|
return getAllPendingMinidumpsIDs();
|
|
|
|
},
|
|
|
|
|
2012-12-11 14:06:48 -08:00
|
|
|
/**
|
|
|
|
* Prune the saved dumps.
|
|
|
|
*/
|
|
|
|
pruneSavedDumps: function CrashSubmit_pruneSavedDumps() {
|
|
|
|
pruneSavedDumps();
|
|
|
|
},
|
|
|
|
|
2010-02-09 17:05:31 -08:00
|
|
|
// List of currently active submit objects
|
|
|
|
_activeSubmissions: []
|
|
|
|
};
|
|
|
|
|
|
|
|
// Run this when first loaded
|
2010-02-15 19:29:00 -08:00
|
|
|
getL10nStrings();
|