win: Initialize exception handler.

This commit is contained in:
Cheng Zhao 2013-11-19 21:37:02 +08:00
parent 2228184066
commit 4105527d07
2 changed files with 49 additions and 4 deletions

View file

@ -4,17 +4,15 @@
#include "common/crash_reporter/crash_reporter_win.h" #include "common/crash_reporter/crash_reporter_win.h"
#include "base/logging.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
namespace crash_reporter { namespace crash_reporter {
CrashReporterWin::CrashReporterWin() CrashReporterWin::CrashReporterWin() {
: breakpad_(NULL) {
} }
CrashReporterWin::~CrashReporterWin() { CrashReporterWin::~CrashReporterWin() {
if (breakpad_ != NULL)
BreakpadRelease(breakpad_);
} }
void CrashReporterWin::InitBreakpad(const std::string& product_name, void CrashReporterWin::InitBreakpad(const std::string& product_name,
@ -23,12 +21,43 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
const std::string& submit_url, const std::string& submit_url,
bool auto_submit, bool auto_submit,
bool skip_system_crash_handler) { bool skip_system_crash_handler) {
skip_system_crash_handler_ = skip_system_crash_handler;
wchar_t temp_dir[MAX_PATH] = { 0 };
::GetTempPathW(MAX_PATH, temp_dir);
breakpad_.reset(new google_breakpad::ExceptionHandler(temp_dir,
FilterCallback,
MinidumpCallback,
this,
google_breakpad::ExceptionHandler::HANDLER_ALL));
} }
void CrashReporterWin::SetUploadParameters() { void CrashReporterWin::SetUploadParameters() {
upload_parameters_["platform"] = "win32"; upload_parameters_["platform"] = "win32";
} }
// static
bool CrashReporterWin::FilterCallback(void* context,
EXCEPTION_POINTERS* exinfo,
MDRawAssertionInfo* assertion) {
return true;
}
// static
bool CrashReporterWin::MinidumpCallback(const wchar_t* dump_path,
const wchar_t* minidump_id,
void* context,
EXCEPTION_POINTERS* exinfo,
MDRawAssertionInfo* assertion,
bool succeeded) {
CrashReporterWin* self = static_cast<CrashReporterWin*>(context);
if (succeeded && !self->skip_system_crash_handler_)
return true;
else
return false;
}
// static // static
CrashReporterWin* CrashReporterWin::GetInstance() { CrashReporterWin* CrashReporterWin::GetInstance() {
return Singleton<CrashReporterWin>::get(); return Singleton<CrashReporterWin>::get();

View file

@ -6,7 +6,9 @@
#define ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_WIN_H_ #define ATOM_COMMON_CRASH_REPORTER_CRASH_REPORTER_WIN_H_
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "common/crash_reporter/crash_reporter.h" #include "common/crash_reporter/crash_reporter.h"
#include "vendor/breakpad/src/client/windows/handler/exception_handler.h"
template <typename T> struct DefaultSingletonTraits; template <typename T> struct DefaultSingletonTraits;
@ -30,6 +32,20 @@ class CrashReporterWin : public CrashReporter {
CrashReporterWin(); CrashReporterWin();
virtual ~CrashReporterWin(); virtual ~CrashReporterWin();
static bool FilterCallback(void* context,
EXCEPTION_POINTERS* exinfo,
MDRawAssertionInfo* assertion);
static bool MinidumpCallback(const wchar_t* dump_path,
const wchar_t* minidump_id,
void* context,
EXCEPTION_POINTERS* exinfo,
MDRawAssertionInfo* assertion,
bool succeeded);
bool skip_system_crash_handler_;
scoped_ptr<google_breakpad::ExceptionHandler> breakpad_;
DISALLOW_COPY_AND_ASSIGN(CrashReporterWin); DISALLOW_COPY_AND_ASSIGN(CrashReporterWin);
}; };