From 6b02be6da873192f7e51dc458fc99f90135e8006 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 14 Nov 2013 18:02:15 +0800 Subject: [PATCH] Add extra uploading parameters for crash reporter. --- common/crash_reporter/crash_reporter.cc | 14 +++++++++++--- common/crash_reporter/crash_reporter.h | 4 ++++ common/crash_reporter/crash_reporter_mac.h | 1 + common/crash_reporter/crash_reporter_mac.mm | 11 +++++++++++ common/crash_reporter/crash_reporter_win.cc | 4 ++++ common/crash_reporter/crash_reporter_win.h | 1 + 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/common/crash_reporter/crash_reporter.cc b/common/crash_reporter/crash_reporter.cc index 0e238138..8e63cbfe 100644 --- a/common/crash_reporter/crash_reporter.cc +++ b/common/crash_reporter/crash_reporter.cc @@ -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 diff --git a/common/crash_reporter/crash_reporter.h b/common/crash_reporter/crash_reporter.h index 73de0a3b..d9a57e71 100644 --- a/common/crash_reporter/crash_reporter.h +++ b/common/crash_reporter/crash_reporter.h @@ -5,6 +5,7 @@ #ifndef ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_ #define ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_H_ +#include #include #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 StringMap; + StringMap upload_parameters_; bool is_browser_; private: diff --git a/common/crash_reporter/crash_reporter_mac.h b/common/crash_reporter/crash_reporter_mac.h index 8b62699f..800de9c8 100644 --- a/common/crash_reporter/crash_reporter_mac.h +++ b/common/crash_reporter/crash_reporter_mac.h @@ -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; diff --git a/common/crash_reporter/crash_reporter_mac.mm b/common/crash_reporter/crash_reporter_mac.mm index 970768cb..8502b92e 100644 --- a/common/crash_reporter/crash_reporter_mac.mm +++ b/common/crash_reporter/crash_reporter_mac.mm @@ -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 diff --git a/common/crash_reporter/crash_reporter_win.cc b/common/crash_reporter/crash_reporter_win.cc index ee8cbe77..60da71ec 100644 --- a/common/crash_reporter/crash_reporter_win.cc +++ b/common/crash_reporter/crash_reporter_win.cc @@ -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::get(); diff --git a/common/crash_reporter/crash_reporter_win.h b/common/crash_reporter/crash_reporter_win.h index 49c17ed1..af7b0634 100644 --- a/common/crash_reporter/crash_reporter_win.h +++ b/common/crash_reporter/crash_reporter_win.h @@ -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; -- 2.43.0