Support removing extra parameters

This commit is contained in:
Kevin Sawicki 2017-02-09 13:05:23 -08:00
parent 41fef3999c
commit 3b7207da9f
6 changed files with 23 additions and 3 deletions

View file

@ -31,14 +31,21 @@ struct Converter<CrashReporter::UploadReportResult> {
namespace {
void SetExtraParameter(const std::string& key, mate::Arguments* args) {
std::string value;
if (args->GetNext(&value))
CrashReporter::GetInstance()->SetExtraParameter(key, value);
else
CrashReporter::GetInstance()->RemoveExtraParameter(key);
}
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 reporter = base::Unretained(CrashReporter::GetInstance());
dict.SetMethod("start", base::Bind(&CrashReporter::Start, reporter));
dict.SetMethod("setExtraParameter",
base::Bind(&CrashReporter::SetExtraParameter, reporter));
dict.SetMethod("setExtraParameter", &SetExtraParameter);
dict.SetMethod("getUploadedReports",
base::Bind(&CrashReporter::GetUploadedReports, reporter));
dict.SetMethod("setUploadToServer",