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 {
|
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,
|
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Context> context, void* priv) {
|
||||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
auto reporter = base::Unretained(CrashReporter::GetInstance());
|
auto reporter = base::Unretained(CrashReporter::GetInstance());
|
||||||
dict.SetMethod("start", base::Bind(&CrashReporter::Start, reporter));
|
dict.SetMethod("start", base::Bind(&CrashReporter::Start, reporter));
|
||||||
dict.SetMethod("setExtraParameter",
|
dict.SetMethod("setExtraParameter", &SetExtraParameter);
|
||||||
base::Bind(&CrashReporter::SetExtraParameter, reporter));
|
|
||||||
dict.SetMethod("getUploadedReports",
|
dict.SetMethod("getUploadedReports",
|
||||||
base::Bind(&CrashReporter::GetUploadedReports, reporter));
|
base::Bind(&CrashReporter::GetUploadedReports, reporter));
|
||||||
dict.SetMethod("setUploadToServer",
|
dict.SetMethod("setUploadToServer",
|
||||||
|
|
|
@ -90,6 +90,9 @@ void CrashReporter::SetExtraParameter(const std::string& key,
|
||||||
const std::string& value) {
|
const std::string& value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CrashReporter::RemoveExtraParameter(const std::string& key) {
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(OS_MACOSX) && defined(MAS_BUILD)
|
#if defined(OS_MACOSX) && defined(MAS_BUILD)
|
||||||
// static
|
// static
|
||||||
CrashReporter* CrashReporter::GetInstance() {
|
CrashReporter* CrashReporter::GetInstance() {
|
||||||
|
|
|
@ -39,6 +39,7 @@ class CrashReporter {
|
||||||
virtual bool GetUploadToServer();
|
virtual bool GetUploadToServer();
|
||||||
virtual void SetExtraParameter(const std::string& key,
|
virtual void SetExtraParameter(const std::string& key,
|
||||||
const std::string& value);
|
const std::string& value);
|
||||||
|
virtual void RemoveExtraParameter(const std::string& key);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CrashReporter();
|
CrashReporter();
|
||||||
|
|
|
@ -36,6 +36,7 @@ class CrashReporterMac : public CrashReporter {
|
||||||
bool GetUploadToServer() override;
|
bool GetUploadToServer() override;
|
||||||
void SetExtraParameter(const std::string& key,
|
void SetExtraParameter(const std::string& key,
|
||||||
const std::string& value) override;
|
const std::string& value) override;
|
||||||
|
void RemoveExtraParameter(const std::string& key) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct base::DefaultSingletonTraits<CrashReporterMac>;
|
friend struct base::DefaultSingletonTraits<CrashReporterMac>;
|
||||||
|
|
|
@ -108,6 +108,13 @@ void CrashReporterMac::SetExtraParameter(const std::string& key,
|
||||||
upload_parameters_[key] = value;
|
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>
|
std::vector<CrashReporter::UploadReportResult>
|
||||||
CrashReporterMac::GetUploadedReports(const base::FilePath& crashes_dir) {
|
CrashReporterMac::GetUploadedReports(const base::FilePath& crashes_dir) {
|
||||||
std::vector<CrashReporter::UploadReportResult> uploaded_reports;
|
std::vector<CrashReporter::UploadReportResult> uploaded_reports;
|
||||||
|
|
|
@ -118,7 +118,8 @@ called before `start` is called.
|
||||||
### `crashReporter.setExtraParameter(key, value)` _macOS_
|
### `crashReporter.setExtraParameter(key, value)` _macOS_
|
||||||
|
|
||||||
* `key` String - Parameter key.
|
* `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
|
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
|
here will be sent in addition to any values set via the `extra` option to
|
||||||
|
|
Loading…
Reference in a new issue