feat: crashReporter: expose rateLimit and compress options (#23062)

This commit is contained in:
Jeremy Apthorp 2020-04-14 10:36:31 -07:00 committed by GitHub
parent fdf7e288bb
commit aeaccd00a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 58 additions and 21 deletions

View file

@ -52,12 +52,14 @@ void CrashReporter::Start(const std::string& product_name,
const base::FilePath& crashes_dir,
bool upload_to_server,
bool skip_system_crash_handler,
bool rate_limit,
bool compress,
const StringMap& extra_parameters) {
is_initialized_ = true;
SetUploadParameters(extra_parameters);
Init(product_name, company_name, submit_url, crashes_dir, upload_to_server,
skip_system_crash_handler);
skip_system_crash_handler, rate_limit, compress);
}
void CrashReporter::SetUploadParameters(const StringMap& parameters) {
@ -105,7 +107,9 @@ void CrashReporter::Init(const std::string& product_name,
const std::string& submit_url,
const base::FilePath& crashes_dir,
bool auto_submit,
bool skip_system_crash_handler) {}
bool skip_system_crash_handler,
bool rate_limit,
bool compress) {}
void CrashReporter::SetUploadParameters() {}
@ -141,12 +145,20 @@ void CrashReporter::StartInstance(const gin_helper::Dictionary& options) {
options.Get("crashesDirectory", &crashes_dir);
StringMap extra_parameters;
options.Get("extra", &extra_parameters);
bool rate_limit = false;
options.Get("rateLimit", &rate_limit);
bool compress = false;
options.Get("compress", &compress);
extra_parameters["_productName"] = product_name;
extra_parameters["_companyName"] = company_name;
reporter->Start(product_name, company_name, submit_url, crashes_dir, true,
false, extra_parameters);
bool upload_to_server = true;
bool skip_system_crash_handler = false;
reporter->Start(product_name, company_name, submit_url, crashes_dir,
upload_to_server, skip_system_crash_handler, rate_limit,
compress, extra_parameters);
}
} // namespace crash_reporter

View file

@ -40,6 +40,8 @@ class CrashReporter {
const base::FilePath& crashes_dir,
bool upload_to_server,
bool skip_system_crash_handler,
bool rate_limit,
bool compress,
const StringMap& extra_parameters);
virtual std::vector<CrashReporter::UploadReportResult> GetUploadedReports(
@ -61,7 +63,9 @@ class CrashReporter {
const std::string& submit_url,
const base::FilePath& crashes_dir,
bool upload_to_server,
bool skip_system_crash_handler);
bool skip_system_crash_handler,
bool rate_limit,
bool compress);
virtual void SetUploadParameters();
StringMap upload_parameters_;

View file

@ -61,7 +61,9 @@ void CrashReporterLinux::Init(const std::string& product_name,
const std::string& submit_url,
const base::FilePath& crashes_dir,
bool upload_to_server,
bool skip_system_crash_handler) {
bool skip_system_crash_handler,
bool rate_limit,
bool compress) {
EnableCrashDumping(crashes_dir);
upload_url_ = submit_url;

View file

@ -33,7 +33,9 @@ class CrashReporterLinux : public CrashReporter {
const std::string& submit_url,
const base::FilePath& crashes_dir,
bool upload_to_server,
bool skip_system_crash_handler) override;
bool skip_system_crash_handler,
bool rate_limit,
bool compress) override;
void SetUploadToServer(bool upload_to_server) override;
void SetUploadParameters() override;
bool GetUploadToServer() override;

View file

@ -26,7 +26,9 @@ class CrashReporterMac : public CrashReporterCrashpad {
const std::string& submit_url,
const base::FilePath& crashes_dir,
bool upload_to_server,
bool skip_system_crash_handler) override;
bool skip_system_crash_handler,
bool rate_limit,
bool compress) override;
void SetUploadParameters() override;
private:

View file

@ -27,7 +27,9 @@ void CrashReporterMac::Init(const std::string& product_name,
const std::string& submit_url,
const base::FilePath& crashes_dir,
bool upload_to_server,
bool skip_system_crash_handler) {
bool skip_system_crash_handler,
bool rate_limit,
bool compress) {
// check whether crashpad has been initialized.
// Only need to initialize once.
if (simple_string_dictionary_)
@ -39,10 +41,11 @@ void CrashReporterMac::Init(const std::string& product_name,
base::FilePath handler_path =
framework_bundle_path.Append("Resources").Append("crashpad_handler");
std::vector<std::string> args = {
"--no-rate-limit",
"--no-upload-gzip", // not all servers accept gzip
};
std::vector<std::string> args;
if (!rate_limit)
args.emplace_back("--no-rate-limit");
if (!compress)
args.emplace_back("--no-upload-gzip");
crashpad::CrashpadClient crashpad_client;
crashpad_client.StartHandler(handler_path, crashes_dir, crashes_dir,

View file

@ -62,7 +62,9 @@ void CrashReporterWin::Init(const std::string& product_name,
const std::string& submit_url,
const base::FilePath& crashes_dir,
bool upload_to_server,
bool skip_system_crash_handler) {
bool skip_system_crash_handler,
bool rate_limit,
bool compress) {
// check whether crashpad has been initialized.
// Only need to initialize once.
if (simple_string_dictionary_)
@ -71,10 +73,11 @@ void CrashReporterWin::Init(const std::string& product_name,
base::FilePath handler_path;
base::PathService::Get(base::FILE_EXE, &handler_path);
std::vector<std::string> args = {
"--no-rate-limit",
"--no-upload-gzip", // not all servers accept gzip
};
std::vector<std::string> args;
if (!rate_limit)
args.emplace_back("--no-rate-limit");
if (!compress)
args.emplace_back("--no-upload-gzip");
args.push_back(base::StringPrintf("--type=%s", kCrashpadProcess));
args.push_back(
base::StringPrintf("--%s=%s", kCrashesDirectoryKey,

View file

@ -30,7 +30,9 @@ class CrashReporterWin : public CrashReporterCrashpad {
const std::string& submit_url,
const base::FilePath& crashes_dir,
bool upload_to_server,
bool skip_system_crash_handler) override;
bool skip_system_crash_handler,
bool rate_limit,
bool compress) override;
void SetUploadParameters() override;
crashpad::CrashpadClient& GetCrashpadClient();