bug 394490 - pending extra and dmp files should be deleted when not submitting report. r=dcamp

This commit is contained in:
ted.mielczarek%gmail.com 2008-01-25 11:24:02 +00:00
Родитель a68df87cb1
Коммит 4aae70ac78
6 изменённых файлов: 45 добавлений и 18 удалений

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

@ -324,17 +324,21 @@ static bool AddSubmittedReport(const string& serverResponse)
return true;
}
void DeleteDump()
{
const char* noDelete = getenv("MOZ_CRASHREPORTER_NO_DELETE_DUMP");
if (!noDelete || *noDelete == '\0') {
if (!gDumpFile.empty())
UIDeleteFile(gDumpFile);
if (!gExtraFile.empty())
UIDeleteFile(gExtraFile);
}
}
bool SendCompleted(bool success, const string& serverResponse)
{
if (success) {
const char* noDelete = getenv("MOZ_CRASHREPORTER_NO_DELETE_DUMP");
if (!noDelete || *noDelete == '\0') {
if (!gDumpFile.empty())
UIDeleteFile(gDumpFile);
if (!gExtraFile.empty())
UIDeleteFile(gExtraFile);
}
DeleteDump();
return AddSubmittedReport(serverResponse);
}
return true;
@ -508,7 +512,8 @@ int main(int argc, char** argv)
sendURL = urlEnv;
}
UIShowCrashUI(gDumpFile, queryParameters, sendURL, restartArgs);
if (!UIShowCrashUI(gDumpFile, queryParameters, sendURL, restartArgs))
DeleteDump();
}
UIShutdown();

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

@ -100,6 +100,7 @@ namespace CrashReporter {
StringTable& strings,
bool escape);
void LogMessage(const std::string& message);
void DeleteDump();
}
//=============================================================================
@ -113,7 +114,9 @@ void UIShutdown();
void UIShowDefaultUI();
// Run the UI for when the app was launched with a dump file
void UIShowCrashUI(const std::string& dumpfile,
// Return true if the user sent (or tried to send) the crash report,
// false if they chose not to, and it should be deleted.
bool UIShowCrashUI(const std::string& dumpfile,
const StringTable& queryParameters,
const std::string& sendURL,
const std::vector<std::string>& restartArgs);

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

@ -73,6 +73,7 @@ static GtkWidget* gCloseButton = 0;
static GtkWidget* gRestartButton = 0;
static bool gInitialized = false;
static bool gDidTrySend = false;
static string gDumpFile;
static StringTable gQueryParameters;
static string gSendURL;
@ -278,6 +279,7 @@ static void RestartClicked(GtkButton* button,
RestartApplication();
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck))) {
gDidTrySend = true;
SendReport();
} else {
gtk_main_quit();
@ -545,7 +547,7 @@ void UIShowDefaultUI()
gtk_dialog_run(GTK_DIALOG(errorDialog));
}
void UIShowCrashUI(const string& dumpfile,
bool UIShowCrashUI(const string& dumpfile,
const StringTable& queryParameters,
const string& sendURL,
const vector<string>& restartArgs)
@ -719,6 +721,8 @@ void UIShowCrashUI(const string& dumpfile,
gtk_widget_hide_all(gThrobber);
gtk_main();
return gDidTrySend;
}
void UIError_impl(const string& message)

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

@ -97,6 +97,7 @@
- (void)uploadComplete:(id)data;
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication;
-(void)applicationWillTerminate:(NSNotification *)aNotification;
@end

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

@ -58,6 +58,7 @@ static StringTable gQueryParameters;
static string gURLParameter;
static string gSendURL;
static vector<string> gRestartArgs;
static bool gDidTrySend = false;
#define NSSTR(s) [NSString stringWithUTF8String:(s).c_str()]
@ -276,6 +277,7 @@ static bool RestartApplication()
// Hide the dialog after "closing", but leave it around to coordinate
// with the upload thread
[window orderOut:nil];
gDidTrySend = true;
[self sendReport];
} else {
[NSApp terminate:self];
@ -289,6 +291,7 @@ static bool RestartApplication()
// Hide the dialog after "closing", but leave it around to coordinate
// with the upload thread
[window orderOut:nil];
gDidTrySend = true;
[self sendReport];
} else {
[NSApp terminate:self];
@ -488,6 +491,14 @@ static bool RestartApplication()
return NO;
}
-(void)applicationWillTerminate:(NSNotification *)aNotification
{
// since we use [NSApp terminate:] we never return to main,
// so do our cleanup here
if (!gDidTrySend)
DeleteDump();
}
@end
/* === Crashreporter UI Functions === */
@ -512,7 +523,7 @@ void UIShowDefaultUI()
[NSApp run];
}
void UIShowCrashUI(const string& dumpfile,
bool UIShowCrashUI(const string& dumpfile,
const StringTable& queryParameters,
const string& sendURL,
const vector<string>& restartArgs)
@ -523,6 +534,8 @@ void UIShowCrashUI(const string& dumpfile,
queryParameters: queryParameters
sendURL: sendURL];
[NSApp run];
return gDidTrySend;
}
void UIError_impl(const string& message)

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

@ -911,7 +911,7 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
Str(ST_REPORTSUBMITSUCCESS).c_str() :
Str(ST_SUBMITFAILED).c_str());
// close dialog after 5 seconds
SetTimer(hwndDlg, success ? 1 : 0, 5000, NULL);
SetTimer(hwndDlg, 0, 5000, NULL);
//
return TRUE;
}
@ -932,8 +932,9 @@ static BOOL CALLBACK CrashReporterDialogProc(HWND hwndDlg, UINT message,
}
case WM_TIMER: {
// wParam is the second parameter from SetTimer above
EndCrashReporterDialog(hwndDlg, wParam);
// The "1" gets used down in UIShowCrashUI to indicate that we at least
// tried to send the report.
EndCrashReporterDialog(hwndDlg, 1);
return FALSE;
}
@ -1027,7 +1028,7 @@ void UIShowDefaultUI()
MB_OK | MB_ICONSTOP);
}
void UIShowCrashUI(const string& dumpFile,
bool UIShowCrashUI(const string& dumpFile,
const StringTable& queryParameters,
const string& sendURL,
const vector<string>& restartArgs)
@ -1055,8 +1056,8 @@ void UIShowCrashUI(const string& dumpFile,
gRestartArgs = restartArgs;
DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_SENDDIALOG), NULL,
(DLGPROC)CrashReporterDialogProc, 0);
return DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_SENDDIALOG), NULL,
(DLGPROC)CrashReporterDialogProc, 0) == 1;
}
void UIError_impl(const string& message)