зеркало из https://github.com/mozilla/gecko-dev.git
Bug 539048 - Hacky temporary UI for sending plugin-process crash reports, r=ted
--HG-- extra : rebase_source : e66e568a174ba975c42006becb6397d55032c3e2
This commit is contained in:
Родитель
56fe91e3d0
Коммит
6f14c1ef50
|
@ -144,17 +144,22 @@ function submitSuccess(ret, link, dump, extra) {
|
|||
// report an error? not much the user can do here.
|
||||
}
|
||||
|
||||
// reset the link to point at our new crash report. this way, if the
|
||||
// user clicks "Back", the link will be correct.
|
||||
let CrashID = ret.CrashID;
|
||||
link.firstChild.textContent = CrashID;
|
||||
link.setAttribute("id", CrashID);
|
||||
link.removeEventListener("click", submitPendingReport, true);
|
||||
if (link) {
|
||||
// reset the link to point at our new crash report. this way, if the
|
||||
// user clicks "Back", the link will be correct.
|
||||
let CrashID = ret.CrashID;
|
||||
link.firstChild.textContent = CrashID;
|
||||
link.setAttribute("id", CrashID);
|
||||
link.removeEventListener("click", submitPendingReport, true);
|
||||
|
||||
if (reportURL) {
|
||||
link.setAttribute("href", reportURL + CrashID);
|
||||
// redirect the user to their brand new crash report
|
||||
window.location.href = reportURL + CrashID;
|
||||
if (reportURL) {
|
||||
link.setAttribute("href", reportURL + CrashID);
|
||||
// redirect the user to their brand new crash report
|
||||
window.location.href = reportURL + CrashID;
|
||||
}
|
||||
}
|
||||
else {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,7 +199,8 @@ function submitForm(iframe, dump, extra, link)
|
|||
if(aFlag & STATE_STOP) {
|
||||
iframe.docShell.removeProgressListener(myListener);
|
||||
myListener = null;
|
||||
link.className = "";
|
||||
if (link)
|
||||
link.className = "";
|
||||
|
||||
//XXX: give some indication of failure?
|
||||
// check general request status first
|
||||
|
@ -233,12 +239,15 @@ function createAndSubmitForm(id, link) {
|
|||
return false;
|
||||
let iframe = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "iframe");
|
||||
iframe.setAttribute("type", "content");
|
||||
iframe.onload = function() {
|
||||
|
||||
function loadHandler() {
|
||||
if (iframe.contentWindow.location == "about:blank")
|
||||
return;
|
||||
iframe.onload = null;
|
||||
iframe.removeEventListener("load", loadHandler, true);
|
||||
submitForm(iframe, dump, extra, link);
|
||||
};
|
||||
}
|
||||
|
||||
iframe.addEventListener("load", loadHandler, true);
|
||||
document.body.appendChild(iframe);
|
||||
iframe.webNavigation.loadURI("chrome://global/content/crash-submit-form.xhtml", 0, null, null, null);
|
||||
return true;
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
// This code is TEMPORARY for submitting crashes via an ugly popup dialog:
|
||||
// bug 525849 tracks the real implementation.
|
||||
|
||||
var id;
|
||||
|
||||
function getExtraData() {
|
||||
let appData = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
|
||||
appData.QueryInterface(Ci.nsICrashReporter);
|
||||
appData.QueryInterface(Ci.nsIXULAppInfo);
|
||||
|
||||
let r = "";
|
||||
r += "ServerURL=" + appData.serverURL.spec + "\n";
|
||||
r += "BuildID=" + appData.appBuildID + "\n";
|
||||
r += "ProductName=" + appData.name + "\n";
|
||||
r += "Vendor=" + appData.vendor + "\n";
|
||||
r += "Version=" + appData.version + "\n";
|
||||
r += "CrashTime=" + ((new Date()).getTime() / 1000).toFixed() + "\n";
|
||||
r += "ProcessType=plugin\n";
|
||||
return r;
|
||||
}
|
||||
|
||||
function collectData() {
|
||||
// HACK: crashes.js uses document.body, so we just alias it
|
||||
document.body = document.getElementById('iframe-holder');
|
||||
|
||||
getL10nStrings();
|
||||
|
||||
let directoryService = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
pendingDir = directoryService.get("UAppData", Ci.nsIFile);
|
||||
pendingDir.append("Crash Reports");
|
||||
pendingDir.append("pending");
|
||||
if (!pendingDir.exists())
|
||||
pendingDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0770);
|
||||
|
||||
reportsDir = directoryService.get("UAppData", Ci.nsIFile);
|
||||
reportsDir.append("Crash Reports");
|
||||
reportsDir.append("submitted");
|
||||
if (!reportsDir.exists())
|
||||
reportsDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0770);
|
||||
|
||||
let dumpFile = window.arguments[0].QueryInterface(Ci.nsIFile);
|
||||
dumpFile.moveTo(pendingDir, "");
|
||||
let leafName = dumpFile.leafName;
|
||||
|
||||
id = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.dmp/(leafName)[1];
|
||||
|
||||
dumpFile = pendingDir.clone();
|
||||
dumpFile.append(leafName);
|
||||
|
||||
let extraFile = pendingDir.clone();
|
||||
extraFile.append(id + ".extra");
|
||||
|
||||
let fstream = Cc["@mozilla.org/network/file-output-stream;1"].
|
||||
createInstance(Ci.nsIFileOutputStream);
|
||||
fstream.init(extraFile, -1, -1, 0);
|
||||
|
||||
var os = Cc["@mozilla.org/intl/converter-output-stream;1"].
|
||||
createInstance(Ci.nsIConverterOutputStream);
|
||||
os.init(fstream, "UTF-8", 0, 0x0000);
|
||||
os.writeString(getExtraData());
|
||||
os.close();
|
||||
fstream.close();
|
||||
}
|
||||
|
||||
function onSubmit()
|
||||
{
|
||||
document.documentElement.getButton('accept').disabled = true;
|
||||
document.documentElement.getButton('accept').label = 'Sending';
|
||||
document.getElementById('throbber').src = 'chrome://global/skin/icons/loading_16.png';
|
||||
createAndSubmitForm(id, null);
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
|
||||
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
id="oopCrashDialog"
|
||||
buttons="accept,cancel"
|
||||
buttonlabelaccept="Send"
|
||||
ondialogaccept="return onSubmit()"
|
||||
onload="collectData()">
|
||||
|
||||
<style xmlns="http://www.w3.org/1999/xhtml" type="text/css">
|
||||
#iframe-holder {
|
||||
visibility: hidden;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="application/javascript;version=1.8" src="chrome://global/content/crashes.js"/>
|
||||
<script type="application/javascript;version=1.8" src="chrome://global/content/oopcrashdialog.js"/>
|
||||
|
||||
<dialogheader title="A Plugin Crashed" />
|
||||
|
||||
<hbox align="center">
|
||||
<description>A plugin crashed while Firefox was running. Please choose to send a crash report
|
||||
to Mozilla. Reloading should cause your plugin to restart.</description>
|
||||
<image width="16" height="16" id="throbber" />
|
||||
</hbox>
|
||||
|
||||
<hbox id="iframe-holder" height="1"/>
|
||||
|
||||
</dialog>
|
|
@ -205,8 +205,9 @@ void ExceptionHandler::Initialize(const wstring& dump_path,
|
|||
}
|
||||
handler_stack_->push_back(this);
|
||||
|
||||
if (handler_types & HANDLER_EXCEPTION)
|
||||
if (handler_types & HANDLER_EXCEPTION) {
|
||||
previous_filter_ = SetUnhandledExceptionFilter(HandleException);
|
||||
}
|
||||
|
||||
#if _MSC_VER >= 1400 // MSVC 2005/8
|
||||
if (handler_types & HANDLER_INVALID_PARAMETER)
|
||||
|
|
|
@ -2,3 +2,5 @@ toolkit.jar:
|
|||
content/global/crashes.xhtml (content/crashes.xhtml)
|
||||
content/global/crashes.js (content/crashes.js)
|
||||
content/global/crash-submit-form.xhtml (content/crash-submit-form.xhtml)
|
||||
content/global/oopcrashdialog.xul (content/oopcrashdialog.xul)
|
||||
content/global/oopcrashdialog.js (content/oopcrashdialog.js)
|
||||
|
|
|
@ -87,6 +87,10 @@
|
|||
#if defined(MOZ_IPC)
|
||||
using google_breakpad::CrashGenerationServer;
|
||||
using google_breakpad::ClientInfo;
|
||||
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#endif
|
||||
|
||||
namespace CrashReporter {
|
||||
|
@ -941,6 +945,31 @@ nsresult AppendObjCExceptionInfoToAppNotes(void *inException)
|
|||
#if defined(MOZ_IPC)
|
||||
//-----------------------------------------------------------------------------
|
||||
// Out-of-process crash reporting API wrappers
|
||||
class SubmitCrashReport : public nsRunnable
|
||||
{
|
||||
public:
|
||||
SubmitCrashReport(nsIFile* dumpFile) : mDumpFile(dumpFile) { }
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
char* e = getenv("MOZ_CRASHREPORTER_NO_REPORT");
|
||||
if (e && *e)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> windowWatcher =
|
||||
do_GetService(NS_WINDOWWATCHER_CONTRACTID);
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
windowWatcher->OpenWindow(nsnull,
|
||||
"chrome://global/content/oopcrashdialog.xul",
|
||||
"_blank",
|
||||
"centerscreen,chrome,titlebar",
|
||||
mDumpFile, getter_AddRefs(newWindow));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIFile> mDumpFile;
|
||||
};
|
||||
|
||||
static void
|
||||
OnChildProcessDumpRequested(void* aContext,
|
||||
const ClientInfo* aClientInfo,
|
||||
|
@ -951,7 +980,16 @@ OnChildProcessDumpRequested(void* aContext,
|
|||
#endif
|
||||
aFilePath)
|
||||
{
|
||||
printf("CHILD DUMP REQUEST\n");
|
||||
nsCOMPtr<nsILocalFile> lf;
|
||||
#ifdef XP_WIN
|
||||
NS_NewLocalFile(nsDependentString(aFilePath->c_str()), PR_FALSE,
|
||||
getter_AddRefs(lf));
|
||||
#else
|
||||
NS_NewNativeLocalFile(nsDependentCString(aFilePath->c_str()), PR_FALSE,
|
||||
getter_AddRefs(lf));
|
||||
#endif
|
||||
nsCOMPtr<nsIRunnable> r = new SubmitCrashReport(lf);
|
||||
NS_DispatchToMainThread(r);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
Загрузка…
Ссылка в новой задаче