Bug 1007534 - Part 2: Support for multiple upload files in the crash reporter clients. r=ted
authorDavid Major <dmajor@mozilla.com>
Mon, 14 Jul 2014 17:32:24 +1200
changeset 202569 f95219244e18505d92fbfb50ce2ef25e3f2bd6fc
parent 202568 a8d2fb4b02792a96633f0209751ea46e72cc2bef
child 202570 fc77de51d4b65cdc898745c30ed8e4dde653cc9c
push id48449
push userdmajor@mozilla.com
push dateSat, 30 Aug 2014 06:06:52 +0000
treeherdermozilla-inbound@bf7861340733 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1007534
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1007534 - Part 2: Support for multiple upload files in the crash reporter clients. r=ted
toolkit/crashreporter/client/crashreporter.cpp
toolkit/crashreporter/client/crashreporter.h
toolkit/crashreporter/client/crashreporter_gtk_common.cpp
toolkit/crashreporter/client/crashreporter_gtk_common.h
toolkit/crashreporter/client/crashreporter_linux.cpp
toolkit/crashreporter/client/crashreporter_osx.h
toolkit/crashreporter/client/crashreporter_osx.mm
toolkit/crashreporter/client/crashreporter_win.cpp
--- a/toolkit/crashreporter/client/crashreporter.cpp
+++ b/toolkit/crashreporter/client/crashreporter.cpp
@@ -632,17 +632,20 @@ int main(int argc, char** argv)
      // 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;
      }
 
-    if (!UIShowCrashUI(gReporterDumpFile, queryParameters, sendURL, restartArgs))
+    StringTable files;
+    files["upload_file_minidump"] = gReporterDumpFile;
+
+    if (!UIShowCrashUI(files, queryParameters, sendURL, restartArgs))
       DeleteDump();
   }
 
   UIShutdown();
 
   return 0;
 }
 
--- a/toolkit/crashreporter/client/crashreporter.h
+++ b/toolkit/crashreporter/client/crashreporter.h
@@ -120,17 +120,17 @@ bool UIInit();
 void UIShutdown();
 
 // Run the UI for when the app was launched without a dump file
 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<std::string>& restartArgs);
 
 void UIError_impl(const std::string& message);
 
 bool UIGetIniPath(std::string& path);
 bool UIGetSettingsPath(const std::string& vendor,
--- a/toolkit/crashreporter/client/crashreporter_gtk_common.cpp
+++ b/toolkit/crashreporter/client/crashreporter_gtk_common.cpp
@@ -42,17 +42,17 @@ GtkWidget* gSubmitReportCheck = 0;
 GtkWidget* gIncludeURLCheck = 0;
 GtkWidget* gThrobber = 0;
 GtkWidget* gProgressLabel = 0;
 GtkWidget* gCloseButton = 0;
 GtkWidget* gRestartButton = 0;
 
 bool gInitialized = false;
 bool gDidTrySend = false;
-string gDumpFile;
+StringTable gFiles;
 StringTable gQueryParameters;
 string gHttpProxy;
 string gAuth;
 string gCACertificateFile;
 string gSendURL;
 string gURLParameter;
 vector<string> gRestartArgs;
 GThread* gSendThreadID;
@@ -188,23 +188,20 @@ void LoadProxyinfo()
 }
 #endif
 
 gpointer SendThread(gpointer args)
 {
   string response, error;
   long response_code;
 
-  std::map<string, string> files;
-  files["upload_file_minidump"] = gDumpFile;
-
   bool success = google_breakpad::HTTPUpload::SendRequest
     (gSendURL,
      gQueryParameters,
-     files,
+     gFiles,
      gHttpProxy, gAuth,
      gCACertificateFile,
      &response,
      &response_code,
      &error);
   if (success) {
     LogMessage("Crash report submitted successfully");
   }
--- a/toolkit/crashreporter/client/crashreporter_gtk_common.h
+++ b/toolkit/crashreporter/client/crashreporter_gtk_common.h
@@ -21,17 +21,17 @@ extern GtkWidget* gProgressLabel;
 extern GtkWidget* gCloseButton;
 extern GtkWidget* gRestartButton;
 
 extern std::vector<std::string> gRestartArgs;
 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;
 extern std::string gCACertificateFile;
 extern std::string gSendURL;
 extern std::string gURLParameter;
 
 void LoadProxyinfo();
--- a/toolkit/crashreporter/client/crashreporter_linux.cpp
+++ b/toolkit/crashreporter/client/crashreporter_linux.cpp
@@ -372,22 +372,22 @@ void TryInitGnome()
 
 void UIShutdown()
 {
   if (gnomeuiLib)
     dlclose(gnomeuiLib);
   // 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<string>& restartArgs)
 {
-  gDumpFile = dumpfile;
+  gFiles = files;
   gQueryParameters = queryParameters;
   gSendURL = sendURL;
   gRestartArgs = restartArgs;
   if (gQueryParameters.find("URL") != gQueryParameters.end())
     gURLParameter = gQueryParameters["URL"];
 
   gWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title(GTK_WINDOW(gWindow),
--- a/toolkit/crashreporter/client/crashreporter_osx.h
+++ b/toolkit/crashreporter/client/crashreporter_osx.h
@@ -41,20 +41,20 @@
     /* For "show info" alert */
     IBOutlet NSWindow* mViewReportWindow;
     IBOutlet NSTextView* mViewReportTextView;
     IBOutlet NSButton* mViewReportOkButton;
 
     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;
 
 - (IBAction)submitReportClicked:(id)sender;
 - (IBAction)viewReportClicked:(id)sender;
 - (IBAction)viewReportOkClicked:(id)sender;
 - (IBAction)closeClicked:(id)sender;
--- a/toolkit/crashreporter/client/crashreporter_osx.mm
+++ b/toolkit/crashreporter/client/crashreporter_osx.mm
@@ -17,17 +17,17 @@
 using std::string;
 using std::vector;
 using std::ostringstream;
 
 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;
 static vector<string> gRestartArgs;
 static bool gDidTrySend = false;
 static bool gRTLlayout = false;
 
 static cpu_type_t pref_cpu_types[2] = {
@@ -98,21 +98,21 @@ static bool RestartApplication()
 {
   gUI = self;
   [mWindow center];
 
   [mWindow setTitle:[[NSBundle mainBundle]
                       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;
 
   [mWindow setTitle:Str(ST_CRASHREPORTERTITLE)];
   [mHeaderLabel setStringValue:Str(ST_CRASHREPORTERHEADER)];
 
   NSRect viewReportFrame = [mViewReportButton frame];
   [mViewReportButton setTitle:Str(ST_VIEWREPORT)];
@@ -568,17 +568,22 @@ static bool RestartApplication()
   for (StringTable::const_iterator i = gQueryParameters.begin();
        i != end;
        i++) {
     NSString* key = NSSTR(i->first);
     NSString* value = NSSTR(i->second);
     [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];
 
   return true;
 }
 
 -(void)uploadComplete:(NSData*)data
 {
@@ -768,24 +773,24 @@ void UIShutdown()
 }
 
 void UIShowDefaultUI()
 {
   [gUI showErrorUI: gStrings[ST_CRASHREPORTERDEFAULT]];
   [NSApp run];
 }
 
-bool UIShowCrashUI(const string& dumpfile,
+bool UIShowCrashUI(const StringTable& files,
                    const StringTable& queryParameters,
                    const string& sendURL,
                    const vector<string>& restartArgs)
 {
   gRestartArgs = restartArgs;
 
-  [gUI showCrashUI: dumpfile
+  [gUI showCrashUI: files
        queryParameters: queryParameters
        sendURL: sendURL];
   [NSApp run];
 
   return gDidTrySend;
 }
 
 void UIError_impl(const string& message)
--- a/toolkit/crashreporter/client/crashreporter_win.cpp
+++ b/toolkit/crashreporter/client/crashreporter_win.cpp
@@ -47,18 +47,18 @@ using std::set;
 using std::ios;
 using std::ifstream;
 using std::ofstream;
 
 using namespace CrashReporter;
 
 typedef struct {
   HWND hDlg;
-  wstring dumpFile;
   map<wstring,wstring> queryParameters;
+  map<wstring,wstring> files;
   wstring sendURL;
 
   wstring serverResponse;
 } SendThreadData;
 
 /*
  * Per http://msdn2.microsoft.com/en-us/library/ms645398(VS.85).aspx
  * "The DLGTEMPLATEEX structure is not defined in any standard header file.
@@ -392,22 +392,19 @@ static DWORD WINAPI SendThreadProc(LPVOI
   bool finishedOk;
   SendThreadData* td = (SendThreadData*)param;
 
   if (td->sendURL.empty()) {
     finishedOk = false;
     LogMessage("No server URL, not sending report");
   } else {
     google_breakpad::CrashReportSender sender(L"");
-    std::map<wstring, wstring> 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) {
       LogMessage("Crash report submitted successfully");
     }
     else {
       // get an error string and print it to the log
       //XXX: would be nice to get the HTTP status code here, filed:
@@ -1291,25 +1288,30 @@ void UIShutdown()
 
 void UIShowDefaultUI()
 {
   MessageBox(nullptr, Str(ST_CRASHREPORTERDEFAULT).c_str(),
              L"Crash Reporter",
              MB_OK | MB_ICONSTOP);
 }
 
-bool UIShowCrashUI(const string& dumpFile,
+bool UIShowCrashUI(const StringTable& files,
                    const StringTable& queryParameters,
                    const string& sendURL,
                    const vector<string>& 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++) {
     gQueryParameters[UTF8ToWide(i->first)] = UTF8ToWide(i->second);
   }
 
   if (gQueryParameters.find(L"Vendor") != gQueryParameters.end()) {
     gCrashReporterKey = L"Software\\";