electron/patches/chromium/crash_allow_setting_more_op...

144 строки
5.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <jeremya@chromium.org>
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 4abce141b758eabd8a16f1cccb0016d5f10c0cae..048a97c807b4249479653cfb70942ec16264d0ee 100644
--- a/components/crash/core/app/crash_reporter_client.cc
+++ b/components/crash/core/app/crash_reporter_client.cc
@@ -145,6 +145,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 a604df7a5ea6a1f5613acc032a65668364aadf89..93a8bf787bdaa0e4251a41453eb22062646f4bcb 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"
@@ -153,6 +154,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 171095381e8acff07ae29531537cdadf76b2c462..8963eade0da26f1494ed26e4b6001f37aca82410 100644
--- a/components/crash/core/app/crashpad_linux.cc
+++ b/components/crash/core/app/crashpad_linux.cc
@@ -231,6 +231,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()) {
@@ -252,6 +253,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) {