Support removing extra parameters
This commit is contained in:
parent
41fef3999c
commit
3b7207da9f
6 changed files with 23 additions and 3 deletions
|
@ -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",
|
||||
|
|
|
@ -90,6 +90,9 @@ void CrashReporter::SetExtraParameter(const std::string& key,
|
|||
const std::string& value) {
|
||||
}
|
||||
|
||||
void CrashReporter::RemoveExtraParameter(const std::string& key) {
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX) && defined(MAS_BUILD)
|
||||
// static
|
||||
CrashReporter* CrashReporter::GetInstance() {
|
||||
|
|
|
@ -39,6 +39,7 @@ class CrashReporter {
|
|||
virtual bool GetUploadToServer();
|
||||
virtual void SetExtraParameter(const std::string& key,
|
||||
const std::string& value);
|
||||
virtual void RemoveExtraParameter(const std::string& key);
|
||||
|
||||
protected:
|
||||
CrashReporter();
|
||||
|
|
|
@ -36,6 +36,7 @@ class CrashReporterMac : public CrashReporter {
|
|||
bool GetUploadToServer() override;
|
||||
void SetExtraParameter(const std::string& key,
|
||||
const std::string& value) override;
|
||||
void RemoveExtraParameter(const std::string& key) override;
|
||||
|
||||
private:
|
||||
friend struct base::DefaultSingletonTraits<CrashReporterMac>;
|
||||
|
|
|
@ -108,6 +108,13 @@ void CrashReporterMac::SetExtraParameter(const std::string& key,
|
|||
upload_parameters_[key] = value;
|
||||
}
|
||||
|
||||
void CrashReporterMac::RemoveExtraParameter(const std::string& key) {
|
||||
if (simple_string_dictionary_)
|
||||
simple_string_dictionary_->RemoveKey(key.data());
|
||||
else
|
||||
upload_parameters_.erase(key);
|
||||
}
|
||||
|
||||
std::vector<CrashReporter::UploadReportResult>
|
||||
CrashReporterMac::GetUploadedReports(const base::FilePath& crashes_dir) {
|
||||
std::vector<CrashReporter::UploadReportResult> uploaded_reports;
|
||||
|
|
|
@ -118,7 +118,8 @@ called before `start` is called.
|
|||
### `crashReporter.setExtraParameter(key, value)` _macOS_
|
||||
|
||||
* `key` String - Parameter key.
|
||||
* `value` String - Parameter value.
|
||||
* `value` String - Parameter value. Specifying `null` or `undefined` will
|
||||
remove the key from the extra parameters.
|
||||
|
||||
Set an extra data to set be sent with the crash report. The values specified
|
||||
here will be sent in addition to any values set via the `extra` option to
|
||||
|
|
Loading…
Reference in a new issue