зеркало из https://github.com/mozilla/gecko-dev.git
Bug 379290 - Add env var to auto submit crashes r=gsvelto
MozReview-Commit-ID: HguIy4GKMb0 --HG-- extra : rebase_source : ae9f9b5276f8b7c8cb448999ce13bd0a13c8eee2
This commit is contained in:
Родитель
5b9ee89503
Коммит
3531136866
|
@ -44,6 +44,7 @@ string gEventsPath;
|
|||
string gPingPath;
|
||||
int gArgc;
|
||||
char** gArgv;
|
||||
bool gAutoSubmit;
|
||||
|
||||
enum SubmissionResult {Succeeded, Failed};
|
||||
|
||||
|
@ -57,6 +58,10 @@ static const char kMemoryReportExtension[] = ".memory.json.gz";
|
|||
|
||||
void UIError(const string& message)
|
||||
{
|
||||
if (gAutoSubmit) {
|
||||
return;
|
||||
}
|
||||
|
||||
string errorMessage;
|
||||
if (!gStrings[ST_CRASHREPORTERERROR].empty()) {
|
||||
char buf[2048];
|
||||
|
@ -647,13 +652,19 @@ int main(int argc, char** argv)
|
|||
gArgc = argc;
|
||||
gArgv = argv;
|
||||
|
||||
string autoSubmitEnv = UIGetEnv("MOZ_CRASHREPORTER_AUTO_SUBMIT");
|
||||
if (!autoSubmitEnv.empty()) {
|
||||
gAutoSubmit = true;
|
||||
}
|
||||
|
||||
if (!ReadConfig()) {
|
||||
UIError("Couldn't read configuration.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!UIInit())
|
||||
if (!UIInit()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc == 3) {
|
||||
if (!strcmp(argv[1], "--full")) {
|
||||
|
@ -666,7 +677,9 @@ int main(int argc, char** argv)
|
|||
|
||||
if (gReporterDumpFile.empty()) {
|
||||
// no dump file specified, run the default UI
|
||||
UIShowDefaultUI();
|
||||
if (!gAutoSubmit) {
|
||||
UIShowDefaultUI();
|
||||
}
|
||||
} else {
|
||||
// Start by running minidump analyzer to gather stack traces.
|
||||
string reporterDumpFile = gReporterDumpFile;
|
||||
|
@ -810,13 +823,13 @@ int main(int argc, char** argv)
|
|||
sendURL = urlEnv;
|
||||
}
|
||||
|
||||
// see if this version has been end-of-lifed
|
||||
if (queryParameters.find("Version") != queryParameters.end() &&
|
||||
CheckEndOfLifed(queryParameters["Version"])) {
|
||||
UIError(gStrings[ST_ERROR_ENDOFLIFE]);
|
||||
DeleteDump();
|
||||
return 0;
|
||||
}
|
||||
// see if this version has been end-of-lifed
|
||||
if (queryParameters.find("Version") != queryParameters.end() &&
|
||||
CheckEndOfLifed(queryParameters["Version"])) {
|
||||
UIError(gStrings[ST_ERROR_ENDOFLIFE]);
|
||||
DeleteDump();
|
||||
return 0;
|
||||
}
|
||||
|
||||
StringTable files;
|
||||
files["upload_file_minidump"] = gReporterDumpFile;
|
||||
|
|
|
@ -93,6 +93,7 @@ namespace CrashReporter {
|
|||
extern std::string gEventsPath;
|
||||
extern int gArgc;
|
||||
extern char** gArgv;
|
||||
extern bool gAutoSubmit;
|
||||
|
||||
void UIError(const std::string& message);
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ GThread* gSendThreadID;
|
|||
// From crashreporter_linux.cpp
|
||||
void SaveSettings();
|
||||
void SendReport();
|
||||
void DisableGUIAndSendReport();
|
||||
void TryInitGnome();
|
||||
void UpdateSubmit();
|
||||
|
||||
|
@ -93,7 +94,9 @@ static bool RestartApplication()
|
|||
// Quit the app, used as a timeout callback
|
||||
static gboolean CloseApp(gpointer data)
|
||||
{
|
||||
gtk_main_quit();
|
||||
if (!gAutoSubmit) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
g_thread_join(gSendThreadID);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -211,10 +214,13 @@ gpointer SendThread(gpointer args)
|
|||
}
|
||||
|
||||
SendCompleted(success, response);
|
||||
// Apparently glib is threadsafe, and will schedule this
|
||||
// on the main thread, see:
|
||||
// http://library.gnome.org/devel/gtk-faq/stable/x499.html
|
||||
g_idle_add(ReportCompleted, (gpointer)success);
|
||||
|
||||
if (!gAutoSubmit) {
|
||||
// Apparently glib is threadsafe, and will schedule this
|
||||
// on the main thread, see:
|
||||
// http://library.gnome.org/devel/gtk-faq/stable/x499.html
|
||||
g_idle_add(ReportCompleted, (gpointer)success);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -243,7 +249,7 @@ static void MaybeSubmitReport()
|
|||
{
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck))) {
|
||||
gDidTrySend = true;
|
||||
SendReport();
|
||||
DisableGUIAndSendReport();
|
||||
} else {
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
|
|
@ -96,6 +96,16 @@ void SaveSettings()
|
|||
}
|
||||
|
||||
void SendReport()
|
||||
{
|
||||
#ifdef MOZ_ENABLE_GCONF
|
||||
LoadProxyinfo();
|
||||
#endif
|
||||
|
||||
// spawn a thread to do the sending
|
||||
gSendThreadID = g_thread_create(SendThread, nullptr, TRUE, nullptr);
|
||||
}
|
||||
|
||||
void DisableGUIAndSendReport()
|
||||
{
|
||||
// disable all our gui controls, show the throbber + change the progress text
|
||||
gtk_widget_set_sensitive(gSubmitReportCheck, FALSE);
|
||||
|
@ -112,13 +122,7 @@ void SendReport()
|
|||
gtk_label_set_text(GTK_LABEL(gProgressLabel),
|
||||
gStrings[ST_REPORTDURINGSUBMIT].c_str());
|
||||
|
||||
#ifdef MOZ_ENABLE_GCONF
|
||||
LoadProxyinfo();
|
||||
#endif
|
||||
|
||||
// and spawn a thread to do the sending
|
||||
GError* err;
|
||||
gSendThreadID = g_thread_create(SendThread, nullptr, TRUE, &err);
|
||||
SendReport();
|
||||
}
|
||||
|
||||
static void ShowReportInfo(GtkTextView* viewReportTextView)
|
||||
|
@ -391,6 +395,12 @@ bool UIShowCrashUI(const StringTable& files,
|
|||
if (gQueryParameters.find("URL") != gQueryParameters.end())
|
||||
gURLParameter = gQueryParameters["URL"];
|
||||
|
||||
if (gAutoSubmit) {
|
||||
SendReport();
|
||||
CloseApp(nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
gWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(gWindow),
|
||||
gStrings[ST_CRASHREPORTERTITLE].c_str());
|
||||
|
|
|
@ -111,6 +111,12 @@ static bool RestartApplication()
|
|||
gQueryParameters = queryParameters;
|
||||
gSendURL = sendURL;
|
||||
|
||||
if (gAutoSubmit) {
|
||||
gDidTrySend = true;
|
||||
[self sendReport];
|
||||
return;
|
||||
}
|
||||
|
||||
[mWindow setTitle:Str(ST_CRASHREPORTERTITLE)];
|
||||
[mHeaderLabel setStringValue:Str(ST_CRASHREPORTERHEADER)];
|
||||
|
||||
|
@ -537,12 +543,17 @@ static bool RestartApplication()
|
|||
{
|
||||
if (![self setupPost]) {
|
||||
LogMessage("Crash report submission failed: could not set up POST data");
|
||||
[self setStringFitVertically:mProgressText
|
||||
|
||||
if (gAutoSubmit) {
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
|
||||
[self setStringFitVertically:mProgressText
|
||||
string:Str(ST_SUBMITFAILED)
|
||||
resizeWindow:YES];
|
||||
// quit after 5 seconds
|
||||
[self performSelector:@selector(closeMeDown:) withObject:nil
|
||||
afterDelay:5.0];
|
||||
// quit after 5 seconds
|
||||
[self performSelector:@selector(closeMeDown:) withObject:nil
|
||||
afterDelay:5.0];
|
||||
}
|
||||
|
||||
[NSThread detachNewThreadSelector:@selector(uploadThread:)
|
||||
|
@ -627,6 +638,10 @@ static bool RestartApplication()
|
|||
|
||||
SendCompleted(success, reply);
|
||||
|
||||
if (gAutoSubmit) {
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
|
||||
[mProgressIndicator stopAnimation:self];
|
||||
if (success) {
|
||||
[self setStringFitVertically:mProgressText
|
||||
|
@ -766,8 +781,12 @@ bool UIInit()
|
|||
gStrings["isRTL"] == "yes")
|
||||
gRTLlayout = true;
|
||||
|
||||
[NSBundle loadNibNamed:(gRTLlayout ? @"MainMenuRTL" : @"MainMenu")
|
||||
owner:NSApp];
|
||||
if (gAutoSubmit) {
|
||||
gUI = [[CrashReporterUI alloc] init];
|
||||
} else {
|
||||
[NSBundle loadNibNamed:(gRTLlayout ? @"MainMenuRTL" : @"MainMenu")
|
||||
owner:NSApp];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -414,7 +414,14 @@ static DWORD WINAPI SendThreadProc(LPVOID param)
|
|||
}
|
||||
}
|
||||
|
||||
PostMessage(td->hDlg, WM_UPLOADCOMPLETE, finishedOk ? 1 : 0, 0);
|
||||
if (gAutoSubmit) {
|
||||
// Ordinarily this is done on the main thread in CrashReporterDialogProc,
|
||||
// for auto submit we don't run that and it should be safe to finish up
|
||||
// here as is done on other platforms.
|
||||
SendCompleted(finishedOk, WideToUTF8(gSendData.serverResponse));
|
||||
} else {
|
||||
PostMessage(td->hDlg, WM_UPLOADCOMPLETE, finishedOk ? 1 : 0, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1357,6 +1364,16 @@ bool UIShowCrashUI(const StringTable& files,
|
|||
gStrings["isRTL"] == "yes")
|
||||
gRTLlayout = true;
|
||||
|
||||
if (gAutoSubmit) {
|
||||
gSendData.queryParameters = gQueryParameters;
|
||||
|
||||
gThreadHandle = CreateThread(nullptr, 0, SendThreadProc, &gSendData, 0,
|
||||
nullptr);
|
||||
WaitForSingleObject(gThreadHandle, INFINITE);
|
||||
// SendCompleted was called from SendThreadProc
|
||||
return true;
|
||||
}
|
||||
|
||||
return 1 == DialogBoxParamMaybeRTL(IDD_SENDDIALOG, nullptr,
|
||||
(DLGPROC)CrashReporterDialogProc, 0);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче