From 9111470b4fca28b496e1ccbb0396db9cec943ff8 Mon Sep 17 00:00:00 2001 From: David Major Date: Mon, 14 Jul 2014 17:32:24 +1200 Subject: [PATCH] Bug 1007534 - Part 2: Support for multiple upload files in the crash reporter clients. r=ted --- toolkit/crashreporter/client/crashreporter.cpp | 5 ++++- toolkit/crashreporter/client/crashreporter.h | 2 +- .../client/crashreporter_gtk_common.cpp | 7 ++----- .../client/crashreporter_gtk_common.h | 2 +- .../client/crashreporter_linux.cpp | 4 ++-- .../crashreporter/client/crashreporter_osx.h | 4 ++-- .../crashreporter/client/crashreporter_osx.mm | 17 +++++++++++------ .../crashreporter/client/crashreporter_win.cpp | 16 +++++++++------- 8 files changed, 32 insertions(+), 25 deletions(-) diff --git a/toolkit/crashreporter/client/crashreporter.cpp b/toolkit/crashreporter/client/crashreporter.cpp index 980de4dc664..eb740a7948e 100644 --- a/toolkit/crashreporter/client/crashreporter.cpp +++ b/toolkit/crashreporter/client/crashreporter.cpp @@ -637,7 +637,10 @@ int main(int argc, char** argv) return 0; } - if (!UIShowCrashUI(gReporterDumpFile, queryParameters, sendURL, restartArgs)) + StringTable files; + files["upload_file_minidump"] = gReporterDumpFile; + + if (!UIShowCrashUI(files, queryParameters, sendURL, restartArgs)) DeleteDump(); } diff --git a/toolkit/crashreporter/client/crashreporter.h b/toolkit/crashreporter/client/crashreporter.h index 01acde3e8cb..c35b26e79a7 100644 --- a/toolkit/crashreporter/client/crashreporter.h +++ b/toolkit/crashreporter/client/crashreporter.h @@ -125,7 +125,7 @@ void UIShowDefaultUI(); // Run the UI for when the app was launched with a dump file // 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, +bool UIShowCrashUI(const StringTable& files, const StringTable& queryParameters, const std::string& sendURL, const std::vector& restartArgs); diff --git a/toolkit/crashreporter/client/crashreporter_gtk_common.cpp b/toolkit/crashreporter/client/crashreporter_gtk_common.cpp index 40706e18216..7f9c30700a1 100644 --- a/toolkit/crashreporter/client/crashreporter_gtk_common.cpp +++ b/toolkit/crashreporter/client/crashreporter_gtk_common.cpp @@ -47,7 +47,7 @@ GtkWidget* gRestartButton = 0; bool gInitialized = false; bool gDidTrySend = false; -string gDumpFile; +StringTable gFiles; StringTable gQueryParameters; string gHttpProxy; string gAuth; @@ -193,13 +193,10 @@ gpointer SendThread(gpointer args) string response, error; long response_code; - std::map files; - files["upload_file_minidump"] = gDumpFile; - bool success = google_breakpad::HTTPUpload::SendRequest (gSendURL, gQueryParameters, - files, + gFiles, gHttpProxy, gAuth, gCACertificateFile, &response, diff --git a/toolkit/crashreporter/client/crashreporter_gtk_common.h b/toolkit/crashreporter/client/crashreporter_gtk_common.h index b2952a79012..3a6350c5b14 100644 --- a/toolkit/crashreporter/client/crashreporter_gtk_common.h +++ b/toolkit/crashreporter/client/crashreporter_gtk_common.h @@ -26,7 +26,7 @@ extern GThread* gSendThreadID; extern bool gInitialized; extern bool gDidTrySend; -extern std::string gDumpFile; +extern StringTable gFiles; extern StringTable gQueryParameters; extern std::string gHttpProxy; extern std::string gAuth; diff --git a/toolkit/crashreporter/client/crashreporter_linux.cpp b/toolkit/crashreporter/client/crashreporter_linux.cpp index 9a8d4c39aa2..fa54bd2ab8a 100644 --- a/toolkit/crashreporter/client/crashreporter_linux.cpp +++ b/toolkit/crashreporter/client/crashreporter_linux.cpp @@ -377,12 +377,12 @@ void UIShutdown() // Don't dlclose gnomeLib as libgnomevfs and libORBit-2 use atexit(). } -bool UIShowCrashUI(const string& dumpfile, +bool UIShowCrashUI(const StringTable& files, const StringTable& queryParameters, const string& sendURL, const vector& restartArgs) { - gDumpFile = dumpfile; + gFiles = files; gQueryParameters = queryParameters; gSendURL = sendURL; gRestartArgs = restartArgs; diff --git a/toolkit/crashreporter/client/crashreporter_osx.h b/toolkit/crashreporter/client/crashreporter_osx.h index f782185923c..e274de0de6c 100644 --- a/toolkit/crashreporter/client/crashreporter_osx.h +++ b/toolkit/crashreporter/client/crashreporter_osx.h @@ -46,10 +46,10 @@ HTTPMultipartUpload* mPost; } -- (void)showCrashUI:(const std::string&)dumpfile +- (void)showCrashUI:(const StringTable&)files queryParameters:(const StringTable&)queryParameters sendURL:(const std::string&)sendURL; -- (void)showErrorUI:(const std::string&)dumpfile; +- (void)showErrorUI:(const std::string&)message; - (void)showReportInfo; - (void)maybeSubmitReport; - (void)closeMeDown:(id)unused; diff --git a/toolkit/crashreporter/client/crashreporter_osx.mm b/toolkit/crashreporter/client/crashreporter_osx.mm index d80a99ce147..94a4197c34c 100644 --- a/toolkit/crashreporter/client/crashreporter_osx.mm +++ b/toolkit/crashreporter/client/crashreporter_osx.mm @@ -22,7 +22,7 @@ using namespace CrashReporter; static NSAutoreleasePool* gMainPool; static CrashReporterUI* gUI = 0; -static string gDumpFile; +static StringTable gFiles; static StringTable gQueryParameters; static string gURLParameter; static string gSendURL; @@ -103,11 +103,11 @@ static bool RestartApplication() objectForInfoDictionaryKey:@"CFBundleName"]]; } --(void)showCrashUI:(const string&)dumpfile +-(void)showCrashUI:(const StringTable&)files queryParameters:(const StringTable&)queryParameters sendURL:(const string&)sendURL { - gDumpFile = dumpfile; + gFiles = files; gQueryParameters = queryParameters; gSendURL = sendURL; @@ -573,7 +573,12 @@ static bool RestartApplication() [parameters setObject: value forKey: key]; } - [mPost addFileAtPath: NSSTR(gDumpFile) name: @"upload_file_minidump"]; + for (StringTable::const_iterator i = gFiles.begin(); + i != gFiles.end(); + i++) { + [mPost addFileAtPath: NSSTR(i->second) name: NSSTR(i->first)]; + } + [mPost setParameters: parameters]; [parameters release]; @@ -773,14 +778,14 @@ void UIShowDefaultUI() [NSApp run]; } -bool UIShowCrashUI(const string& dumpfile, +bool UIShowCrashUI(const StringTable& files, const StringTable& queryParameters, const string& sendURL, const vector& restartArgs) { gRestartArgs = restartArgs; - [gUI showCrashUI: dumpfile + [gUI showCrashUI: files queryParameters: queryParameters sendURL: sendURL]; [NSApp run]; diff --git a/toolkit/crashreporter/client/crashreporter_win.cpp b/toolkit/crashreporter/client/crashreporter_win.cpp index 7ee49167354..b682bdb7bf1 100644 --- a/toolkit/crashreporter/client/crashreporter_win.cpp +++ b/toolkit/crashreporter/client/crashreporter_win.cpp @@ -52,8 +52,8 @@ using namespace CrashReporter; typedef struct { HWND hDlg; - wstring dumpFile; map queryParameters; + map files; wstring sendURL; wstring serverResponse; @@ -397,12 +397,9 @@ static DWORD WINAPI SendThreadProc(LPVOID param) LogMessage("No server URL, not sending report"); } else { google_breakpad::CrashReportSender sender(L""); - std::map files; - files[L"upload_file_minidump"] = td->dumpFile; - finishedOk = (sender.SendCrashReport(td->sendURL, td->queryParameters, - files, + td->files, &td->serverResponse) == google_breakpad::RESULT_SUCCEEDED); if (finishedOk) { @@ -1296,15 +1293,20 @@ void UIShowDefaultUI() MB_OK | MB_ICONSTOP); } -bool UIShowCrashUI(const string& dumpFile, +bool UIShowCrashUI(const StringTable& files, const StringTable& queryParameters, const string& sendURL, const vector& restartArgs) { gSendData.hDlg = nullptr; - gSendData.dumpFile = UTF8ToWide(dumpFile); gSendData.sendURL = UTF8ToWide(sendURL); + for (StringTable::const_iterator i = files.begin(); + i != files.end(); + i++) { + gSendData.files[UTF8ToWide(i->first)] = UTF8ToWide(i->second); + } + for (StringTable::const_iterator i = queryParameters.begin(); i != queryParameters.end(); i++) {