Update crashpad implementation after code review.
This commit is contained in:
parent
51d5ef9d86
commit
317406f26d
3 changed files with 31 additions and 27 deletions
|
@ -9,9 +9,16 @@
|
|||
|
||||
#include "atom/common/crash_reporter/crash_reporter.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "vendor/crashpad/client/simple_string_dictionary.h"
|
||||
|
||||
template <typename T> struct DefaultSingletonTraits;
|
||||
|
||||
namespace crashpad {
|
||||
class CrashReportDatabase;
|
||||
}
|
||||
|
||||
namespace crash_reporter {
|
||||
|
||||
class CrashReporterMac : public CrashReporter {
|
||||
|
@ -32,6 +39,13 @@ class CrashReporterMac : public CrashReporter {
|
|||
CrashReporterMac();
|
||||
virtual ~CrashReporterMac();
|
||||
|
||||
void SetUploadsEnabled(bool enable_uploads);
|
||||
void SetCrashKeyValue(const base::StringPiece& key,
|
||||
const base::StringPiece& value);
|
||||
|
||||
scoped_ptr<crashpad::SimpleStringDictionary> simple_string_dictionary_;
|
||||
scoped_ptr<crashpad::CrashReportDatabase> crash_report_database_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CrashReporterMac);
|
||||
};
|
||||
|
||||
|
|
|
@ -19,25 +19,6 @@
|
|||
|
||||
namespace crash_reporter {
|
||||
|
||||
namespace {
|
||||
|
||||
crashpad::SimpleStringDictionary* g_simple_string_dictionary;
|
||||
crashpad::CrashReportDatabase* g_database;
|
||||
|
||||
void SetUploadsEnabled(bool enable_uploads) {
|
||||
if (g_database) {
|
||||
crashpad::Settings* settings = g_database->GetSettings();
|
||||
settings->SetUploadsEnabled(enable_uploads);
|
||||
}
|
||||
}
|
||||
|
||||
void SetCrashKeyValue(const base::StringPiece& key,
|
||||
const base::StringPiece& value) {
|
||||
g_simple_string_dictionary->SetKeyValue(key.data(), value.data());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CrashReporterMac::CrashReporterMac() {
|
||||
}
|
||||
|
||||
|
@ -64,12 +45,10 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
|
|||
framework_bundle_path.Append("Resources").Append("crashpad_handler");
|
||||
|
||||
crashpad::CrashpadClient crashpad_client;
|
||||
// Send all crash reports.
|
||||
std::vector<std::string> arguments = { "--upload-internal=0" };
|
||||
if (crashpad_client.StartHandler(handler_path, database_path,
|
||||
submit_url,
|
||||
StringMap(),
|
||||
arguments)) {
|
||||
std::vector<std::string>())) {
|
||||
crashpad_client.UseHandler();
|
||||
}
|
||||
} // @autoreleasepool
|
||||
|
@ -82,8 +61,8 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
|
|||
crashpad::TriState::kDisabled);
|
||||
}
|
||||
|
||||
g_simple_string_dictionary = new crashpad::SimpleStringDictionary();
|
||||
crashpad_info->set_simple_annotations(g_simple_string_dictionary);
|
||||
simple_string_dictionary_.reset(new crashpad::SimpleStringDictionary());
|
||||
crashpad_info->set_simple_annotations(simple_string_dictionary_.get());
|
||||
|
||||
SetCrashKeyValue("prod", ATOM_PRODUCT_NAME);
|
||||
SetCrashKeyValue("process_type", is_browser_ ? base::StringPiece("browser")
|
||||
|
@ -95,8 +74,8 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
|
|||
SetCrashKeyValue(iter->first, iter->second);
|
||||
}
|
||||
if (is_browser_) {
|
||||
g_database =
|
||||
crashpad::CrashReportDatabase::Initialize(database_path).release();
|
||||
crash_report_database_ = crashpad::CrashReportDatabase::Initialize(
|
||||
database_path);
|
||||
SetUploadsEnabled(auto_submit);
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +84,18 @@ void CrashReporterMac::SetUploadParameters() {
|
|||
upload_parameters_["platform"] = "darwin";
|
||||
}
|
||||
|
||||
void CrashReporterMac::SetUploadsEnabled(bool enable_uploads) {
|
||||
if (crash_report_database_) {
|
||||
crashpad::Settings* settings = crash_report_database_->GetSettings();
|
||||
settings->SetUploadsEnabled(enable_uploads);
|
||||
}
|
||||
}
|
||||
|
||||
void CrashReporterMac::SetCrashKeyValue(const base::StringPiece& key,
|
||||
const base::StringPiece& value) {
|
||||
simple_string_dictionary_->SetKeyValue(key.data(), value.data());
|
||||
}
|
||||
|
||||
// static
|
||||
CrashReporterMac* CrashReporterMac::GetInstance() {
|
||||
return Singleton<CrashReporterMac>::get();
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
'v8_enable_i18n_support': 'false',
|
||||
# Required by Linux (empty for now, should support it in future).
|
||||
'sysroot': '',
|
||||
'crashpad_standalone': 1,
|
||||
},
|
||||
# Settings to compile node under Windows.
|
||||
'target_defaults': {
|
||||
|
|
Loading…
Reference in a new issue