Add setExtraParameter support on macOS

This commit is contained in:
Kevin Sawicki 2017-02-02 14:23:21 -08:00
parent cfe3ae234b
commit ba975d552a
6 changed files with 27 additions and 6 deletions

View file

@ -35,15 +35,16 @@ namespace {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
auto report = base::Unretained(CrashReporter::GetInstance());
dict.SetMethod("start",
base::Bind(&CrashReporter::Start, report));
auto reporter = base::Unretained(CrashReporter::GetInstance());
dict.SetMethod("start", base::Bind(&CrashReporter::Start, reporter));
dict.SetMethod("setExtraParameter",
base::Bind(&CrashReporter::SetExtraParameter, reporter));
dict.SetMethod("getUploadedReports",
base::Bind(&CrashReporter::GetUploadedReports, report));
base::Bind(&CrashReporter::GetUploadedReports, reporter));
dict.SetMethod("setUploadToServer",
base::Bind(&CrashReporter::SetUploadToServer, report));
base::Bind(&CrashReporter::SetUploadToServer, reporter));
dict.SetMethod("getUploadToServer",
base::Bind(&CrashReporter::GetUploadToServer, report));
base::Bind(&CrashReporter::GetUploadToServer, reporter));
}
} // namespace

View file

@ -86,6 +86,10 @@ void CrashReporter::InitBreakpad(const std::string& product_name,
void CrashReporter::SetUploadParameters() {
}
void CrashReporter::SetExtraParameter(const std::string& key,
const std::string& value) {
}
#if defined(OS_MACOSX) && defined(MAS_BUILD)
// static
CrashReporter* CrashReporter::GetInstance() {

View file

@ -37,6 +37,8 @@ class CrashReporter {
virtual void SetUploadToServer(bool upload_to_server);
virtual bool GetUploadToServer();
virtual void SetExtraParameter(const std::string& key,
const std::string& value);
protected:
CrashReporter();

View file

@ -34,6 +34,8 @@ class CrashReporterMac : public CrashReporter {
void SetUploadParameters() override;
void SetUploadToServer(bool upload_to_server) override;
bool GetUploadToServer() override;
void SetExtraParameter(const std::string& key,
const std::string& value) override;
private:
friend struct base::DefaultSingletonTraits<CrashReporterMac>;

View file

@ -100,6 +100,14 @@ void CrashReporterMac::SetCrashKeyValue(const base::StringPiece& key,
simple_string_dictionary_->SetKeyValue(key.data(), value.data());
}
void CrashReporterMac::SetExtraParameter(const std::string& key,
const std::string& value) {
if (simple_string_dictionary_)
SetCrashKeyValue(key, value);
else
upload_parameters_[key] = value;
}
std::vector<CrashReporter::UploadReportResult>
CrashReporterMac::GetUploadedReports(const base::FilePath& crashes_dir) {
std::vector<CrashReporter::UploadReportResult> uploaded_reports;

View file

@ -117,6 +117,10 @@ class CrashReporter {
throw new Error('setUploadToServer can only be called from the main process')
}
}
setExtraParameter (key, value) {
binding.setExtraParameter(key, value)
}
}
module.exports = new CrashReporter()