diff --git a/docs/api/crash-reporter.md b/docs/api/crash-reporter.md index 33464ccf2c..6ac538dfac 100644 --- a/docs/api/crash-reporter.md +++ b/docs/api/crash-reporter.md @@ -48,6 +48,11 @@ The `crashReporter` module has the following methods: * `productName` String (optional) - Defaults to `app.name`. * `uploadToServer` Boolean (optional) - Whether crash reports should be sent to the server. Default is `true`. * `ignoreSystemCrashHandler` Boolean (optional) - Default is `false`. + * `rateLimit` Boolean (optional) _macOS_ _Windows_ - If true, limit the + number of crashes uploaded to 1/hour. Default is `false`. + * `compress` Boolean (optional) _macOS_ _Windows_ - If true, crash reports + will be compressed and uploaded with `Content-Encoding: gzip`. Not all + collection servers support compressed payloads. Default is `false`. * `extra` Record (optional) - An object you can define that will be sent along with the report. Only string properties are sent correctly. Nested objects are not supported. When using Windows, the property names and values must be fewer than 64 characters. diff --git a/lib/common/crash-reporter.js b/lib/common/crash-reporter.js index 36df08928c..893c09b848 100644 --- a/lib/common/crash-reporter.js +++ b/lib/common/crash-reporter.js @@ -21,7 +21,9 @@ class CrashReporter { extra = {}, ignoreSystemCrashHandler = false, submitURL, - uploadToServer = true + uploadToServer = true, + rateLimit = false, + compress = false } = options; if (companyName == null) throw new Error('companyName is a required option to crashReporter.start'); @@ -39,7 +41,7 @@ class CrashReporter { if (extra._companyName == null) extra._companyName = companyName; if (extra._version == null) extra._version = ret.appVersion; - binding.start(ret.productName, companyName, submitURL, ret.crashesDirectory, uploadToServer, ignoreSystemCrashHandler, extra); + binding.start(ret.productName, companyName, submitURL, ret.crashesDirectory, uploadToServer, ignoreSystemCrashHandler, rateLimit, compress, extra); } getLastCrashReport () { diff --git a/shell/common/crash_reporter/crash_reporter.cc b/shell/common/crash_reporter/crash_reporter.cc index 1fd9a275f7..da112e4602 100644 --- a/shell/common/crash_reporter/crash_reporter.cc +++ b/shell/common/crash_reporter/crash_reporter.cc @@ -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 diff --git a/shell/common/crash_reporter/crash_reporter.h b/shell/common/crash_reporter/crash_reporter.h index 369d9089da..f3afabebf0 100644 --- a/shell/common/crash_reporter/crash_reporter.h +++ b/shell/common/crash_reporter/crash_reporter.h @@ -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 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_; diff --git a/shell/common/crash_reporter/crash_reporter_linux.cc b/shell/common/crash_reporter/crash_reporter_linux.cc index 0d336725f0..ccffddfd36 100644 --- a/shell/common/crash_reporter/crash_reporter_linux.cc +++ b/shell/common/crash_reporter/crash_reporter_linux.cc @@ -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; diff --git a/shell/common/crash_reporter/crash_reporter_linux.h b/shell/common/crash_reporter/crash_reporter_linux.h index 49e1fb8110..9013a70ff6 100644 --- a/shell/common/crash_reporter/crash_reporter_linux.h +++ b/shell/common/crash_reporter/crash_reporter_linux.h @@ -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; diff --git a/shell/common/crash_reporter/crash_reporter_mac.h b/shell/common/crash_reporter/crash_reporter_mac.h index 9747645bb4..92bab58743 100644 --- a/shell/common/crash_reporter/crash_reporter_mac.h +++ b/shell/common/crash_reporter/crash_reporter_mac.h @@ -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: diff --git a/shell/common/crash_reporter/crash_reporter_mac.mm b/shell/common/crash_reporter/crash_reporter_mac.mm index 5a6bc8bcee..cd14cc1277 100644 --- a/shell/common/crash_reporter/crash_reporter_mac.mm +++ b/shell/common/crash_reporter/crash_reporter_mac.mm @@ -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 args = { - "--no-rate-limit", - "--no-upload-gzip", // not all servers accept gzip - }; + std::vector 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, diff --git a/shell/common/crash_reporter/crash_reporter_win.cc b/shell/common/crash_reporter/crash_reporter_win.cc index 0a737901a1..833f767146 100644 --- a/shell/common/crash_reporter/crash_reporter_win.cc +++ b/shell/common/crash_reporter/crash_reporter_win.cc @@ -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 args = { - "--no-rate-limit", - "--no-upload-gzip", // not all servers accept gzip - }; + std::vector 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, diff --git a/shell/common/crash_reporter/crash_reporter_win.h b/shell/common/crash_reporter/crash_reporter_win.h index 2312d85fe7..f410d9cd55 100644 --- a/shell/common/crash_reporter/crash_reporter_win.h +++ b/shell/common/crash_reporter/crash_reporter_win.h @@ -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();