123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: Jeremy Apthorp <[email protected]>
- Date: Thu, 30 Apr 2020 10:08:06 -0700
- Subject: crash: allow setting more options
- This allows the client of //components/crash to set upload url,
- rate-limiting, compression and global annotations.
- This should be upstreamed.
- diff --git a/components/crash/core/app/crash_reporter_client.cc b/components/crash/core/app/crash_reporter_client.cc
- index b6a2910848c66489e70acdce6e09237bf6188f94..744cca2d1b8856719b9ae5aed6c443e8752da75e 100644
- --- a/components/crash/core/app/crash_reporter_client.cc
- +++ b/components/crash/core/app/crash_reporter_client.cc
- @@ -119,6 +119,17 @@ bool CrashReporterClient::ReportingIsEnforcedByPolicy(bool* breakpad_enabled) {
- return false;
- }
-
- +bool CrashReporterClient::GetShouldRateLimit() {
- + return true;
- +}
- +
- +bool CrashReporterClient::GetShouldCompressUploads() {
- + return true;
- +}
- +
- +void CrashReporterClient::GetProcessSimpleAnnotations(std::map<std::string, std::string>* annotations) {
- +}
- +
- #if BUILDFLAG(IS_ANDROID)
- unsigned int CrashReporterClient::GetCrashDumpPercentage() {
- return 100;
- diff --git a/components/crash/core/app/crash_reporter_client.h b/components/crash/core/app/crash_reporter_client.h
- index 7c890b331be4aaaf20c7efe8a4bcc2f6e9012b7a..c573524d05c07ec67d35046bc8548cc1dfdd0df3 100644
- --- a/components/crash/core/app/crash_reporter_client.h
- +++ b/components/crash/core/app/crash_reporter_client.h
- @@ -7,6 +7,7 @@
-
- #include <stdint.h>
-
- +#include <map>
- #include <string>
-
- #include "build/build_config.h"
- @@ -141,6 +142,19 @@ class CrashReporterClient {
- // that case, |breakpad_enabled| is set to the value enforced by policies.
- virtual bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled);
-
- + // Returns true if crash uploads should be rate limited. If false, no
- + // throttling will be applied for uploads.
- + virtual bool GetShouldRateLimit();
- +
- + // Returns true if crash uploads should be compressed with gzip. If false,
- + // reports will be uploaded uncompressed.
- + virtual bool GetShouldCompressUploads();
- +
- + // Allows the client to add or edit global annotations passed to the crashpad
- + // handler.
- + virtual void GetProcessSimpleAnnotations(
- + std::map<std::string, std::string>* annotations);
- +
- #if BUILDFLAG(IS_ANDROID)
- // Used by WebView to sample crashes without generating the unwanted dumps. If
- // the returned value is less than 100, crash dumping will be sampled to that
- diff --git a/components/crash/core/app/crashpad_linux.cc b/components/crash/core/app/crashpad_linux.cc
- index 5d9b3bd5386ecbdb74cc470dbe65308c3afa0a61..dc29a4bedc0533e27affb26367cfcc2c3f9544f3 100644
- --- a/components/crash/core/app/crashpad_linux.cc
- +++ b/components/crash/core/app/crashpad_linux.cc
- @@ -218,6 +218,7 @@ bool PlatformCrashpadInitialization(
- // where crash_reporter provides it's own values for lsb-release.
- annotations["lsb-release"] = base::GetLinuxDistro();
- #endif
- + crash_reporter_client->GetProcessSimpleAnnotations(&annotations);
-
- std::vector<std::string> arguments;
- if (crash_reporter_client->ShouldMonitorCrashHandlerExpensively()) {
- @@ -239,6 +240,13 @@ bool PlatformCrashpadInitialization(
- }
- #endif
-
- + if (!crash_reporter_client->GetShouldRateLimit()) {
- + arguments.push_back("--no-rate-limit");
- + }
- + if (!crash_reporter_client->GetShouldCompressUploads()) {
- + arguments.push_back("--no-upload-gzip");
- + }
- +
- CHECK(client.StartHandler(handler_path, *database_path, metrics_path, url,
- annotations, arguments, false, false));
- } else {
- diff --git a/components/crash/core/app/crashpad_mac.mm b/components/crash/core/app/crashpad_mac.mm
- index 42fe73aefe44f218d6a5e8cb1550ff48859c4b70..a1235f0c7ad44ae9c9fdc805af5b9dc5669f5aad 100644
- --- a/components/crash/core/app/crashpad_mac.mm
- +++ b/components/crash/core/app/crashpad_mac.mm
- @@ -86,6 +86,8 @@
- } // @autoreleasepool
- return process_annotations;
- }();
- + CrashReporterClient* crash_reporter_client = GetCrashReporterClient();
- + crash_reporter_client->GetProcessSimpleAnnotations(&annotations);
- return annotations;
- }
-
- @@ -156,6 +158,13 @@ bool PlatformCrashpadInitialization(
-
- std::vector<std::string> arguments;
-
- + if (!crash_reporter_client->GetShouldRateLimit()) {
- + arguments.push_back("--no-rate-limit");
- + }
- + if (!crash_reporter_client->GetShouldCompressUploads()) {
- + arguments.push_back("--no-upload-gzip");
- + }
- +
- if (crash_reporter_client->ShouldMonitorCrashHandlerExpensively()) {
- arguments.push_back("--monitor-self");
- }
- diff --git a/components/crash/core/app/crashpad_win.cc b/components/crash/core/app/crashpad_win.cc
- index 0e00d26f79231a01e88981b30ff950e427cd31f4..70f014c75031f9529501e102f97e0e1adadb8ffb 100644
- --- a/components/crash/core/app/crashpad_win.cc
- +++ b/components/crash/core/app/crashpad_win.cc
- @@ -92,6 +92,7 @@ bool PlatformCrashpadInitialization(
-
- std::map<std::string, std::string> process_annotations;
- GetPlatformCrashpadAnnotations(&process_annotations);
- + crash_reporter_client->GetProcessSimpleAnnotations(&process_annotations);
-
- std::string url = crash_reporter_client->GetUploadUrl();
-
- @@ -129,6 +130,13 @@ bool PlatformCrashpadInitialization(
-
- std::vector<std::string> arguments(start_arguments);
-
- + if (!crash_reporter_client->GetShouldRateLimit()) {
- + arguments.push_back("--no-rate-limit");
- + }
- + if (!crash_reporter_client->GetShouldCompressUploads()) {
- + arguments.push_back("--no-upload-gzip");
- + }
- +
- if (crash_reporter_client->ShouldMonitorCrashHandlerExpensively()) {
- arguments.push_back("--monitor-self");
- for (const std::string& start_argument : start_arguments) {
|