Add extra uploading parameters for crash reporter.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 14 Nov 2013 10:02:15 +0000 (18:02 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 14 Nov 2013 10:02:15 +0000 (18:02 +0800)
common/crash_reporter/crash_reporter.cc
common/crash_reporter/crash_reporter.h
common/crash_reporter/crash_reporter_mac.h
common/crash_reporter/crash_reporter_mac.mm
common/crash_reporter/crash_reporter_win.cc
common/crash_reporter/crash_reporter_win.h

index 0e23813..8e63cbf 100644 (file)
@@ -12,9 +12,9 @@
 namespace crash_reporter {
 
 CrashReporter::CrashReporter() {
-  const CommandLine& command = *CommandLine::ForCurrentProcess();
-  std::string type = command.GetSwitchValueASCII(switches::kProcessType);
-  is_browser_ = type.empty();
+  SetUploadParameters();
+
+  is_browser_ = upload_parameters_["process_type"].empty();
 }
 
 CrashReporter::~CrashReporter() {
@@ -42,4 +42,12 @@ void CrashReporter::Start(std::string product_name,
                skip_system_crash_handler);
 }
 
+void CrashReporter::SetUploadParameters() {
+  const CommandLine& command = *CommandLine::ForCurrentProcess();
+  std::string type = command.GetSwitchValueASCII(switches::kProcessType);
+
+  upload_parameters_["process_type"] = type;
+  upload_parameters_["atom_shell_version"] = ATOM_VERSION_STRING;
+}
+
 }  // namespace crash_reporter
index 73de0a3..d9a57e7 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_
 #define ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_
 
+#include <map>
 #include <string>
 
 #include "base/basictypes.h"
@@ -31,7 +32,10 @@ class CrashReporter {
                             const std::string& submit_url,
                             bool auto_submit,
                             bool skip_system_crash_handler) = 0;
+  virtual void SetUploadParameters();
 
+  typedef std::map<std::string, std::string> StringMap;
+  StringMap upload_parameters_;
   bool is_browser_;
 
  private:
index 8b62699..800de9c 100644 (file)
@@ -23,6 +23,7 @@ class CrashReporterMac : public CrashReporter {
                             const std::string& submit_url,
                             bool auto_submit,
                             bool skip_system_crash_handler) OVERRIDE;
+  virtual void SetUploadParameters() OVERRIDE;
 
  private:
   friend struct DefaultSingletonTraits<CrashReporterMac>;
index 970768c..8502b92 100644 (file)
@@ -48,6 +48,17 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
   [parameters setValue:@"0" forKey:@BREAKPAD_REPORT_INTERVAL];
 
   breakpad_ = BreakpadCreate(parameters);
+
+  for (StringMap::const_iterator iter = upload_parameters_.begin();
+       iter != upload_parameters_.end(); ++iter) {
+    BreakpadAddUploadParameter(breakpad_,
+                               base::SysUTF8ToNSString(iter->first),
+                               base::SysUTF8ToNSString(iter->second));
+  }
+}
+
+void CrashReporterMac::SetUploadParameters() {
+  upload_parameters_["platform"] = "darwin";
 }
 
 // static
index ee8cbe7..60da71e 100644 (file)
@@ -25,6 +25,10 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
                                     bool skip_system_crash_handler) {
 }
 
+void CrashReporterWin::SetUploadParameters() {
+  upload_parameters_["platform"] = "win32";
+}
+
 // static
 CrashReporterWin* CrashReporterWin::GetInstance() {
   return Singleton<CrashReporterWin>::get();
index 49c17ed..af7b063 100644 (file)
@@ -22,6 +22,7 @@ class CrashReporterWin : public CrashReporter {
                             const std::string& submit_url,
                             bool auto_submit,
                             bool skip_system_crash_handler) OVERRIDE;
+  virtual void SetUploadParameters() OVERRIDE;
 
  private:
   friend struct DefaultSingletonTraits<CrashReporterWin>;