|
@@ -0,0 +1,192 @@
|
|
|
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
+From: Jeremy Apthorp <[email protected]>
|
|
|
+Date: Wed, 13 May 2020 19:06:23 +0000
|
|
|
+Subject: allow embedder to set crash upload url
|
|
|
+
|
|
|
+Currently //components/crash hard-codes the crash report URL to be a
|
|
|
+Google-specific target. This CL adds a hook which allows embedders to override
|
|
|
+this URL. Without it, this module isn't usable for non-Google embedders.
|
|
|
+
|
|
|
+Change-Id: I1251c3ef164f04de63cf8c66165180e897a91d78
|
|
|
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2194585
|
|
|
+Commit-Queue: Jeremy Apthorp <[email protected]>
|
|
|
+Reviewed-by: Robert Sesek <[email protected]>
|
|
|
+Cr-Commit-Position: refs/heads/master@{#768385}
|
|
|
+
|
|
|
+diff --git a/components/crash/core/app/BUILD.gn b/components/crash/core/app/BUILD.gn
|
|
|
+index bb11c401ca7939ca04e90fd13f1b335bf5b60598..af031a027ee3e19e57e9c4d9a133127a3a637003 100644
|
|
|
+--- a/components/crash/core/app/BUILD.gn
|
|
|
++++ b/components/crash/core/app/BUILD.gn
|
|
|
+@@ -22,7 +22,10 @@ source_set("lib") {
|
|
|
+ "crash_reporter_client.h",
|
|
|
+ ]
|
|
|
+
|
|
|
+- deps = [ "//base" ]
|
|
|
++ deps = [
|
|
|
++ "//base",
|
|
|
++ "//build:branding_buildflags",
|
|
|
++ ]
|
|
|
+ }
|
|
|
+
|
|
|
+ source_set("crashpad_handler_main") {
|
|
|
+diff --git a/components/crash/core/app/breakpad_linux.cc b/components/crash/core/app/breakpad_linux.cc
|
|
|
+index 192b0a7f137f311abb6a991f997e11f5eba52256..8ca43e2a8a104c3edf4087df5490fd47cd18f9a4 100644
|
|
|
+--- a/components/crash/core/app/breakpad_linux.cc
|
|
|
++++ b/components/crash/core/app/breakpad_linux.cc
|
|
|
+@@ -103,7 +103,11 @@ namespace {
|
|
|
+ // while we do have functions to deal with uint64_t's.
|
|
|
+ uint64_t g_crash_loop_before_time = 0;
|
|
|
+ #else
|
|
|
+-const char kUploadURL[] = "https://clients2.google.com/cr/report";
|
|
|
++char* g_upload_url = nullptr;
|
|
|
++void SetUploadURL(const std::string& url) {
|
|
|
++ DCHECK(!g_upload_url);
|
|
|
++ g_upload_url = strdup(url.c_str());
|
|
|
++}
|
|
|
+ #endif
|
|
|
+
|
|
|
+ bool g_is_crash_reporter_enabled = false;
|
|
|
+@@ -1400,16 +1404,16 @@ void ExecUploadProcessOrTerminate(const BreakpadInfo& info,
|
|
|
+
|
|
|
+ static const char kWgetBinary[] = "/usr/bin/wget";
|
|
|
+ const char* args[] = {
|
|
|
+- kWgetBinary,
|
|
|
+- header_content_encoding,
|
|
|
+- header_content_type,
|
|
|
+- post_file,
|
|
|
+- kUploadURL,
|
|
|
+- "--timeout=10", // Set a timeout so we don't hang forever.
|
|
|
+- "--tries=1", // Don't retry if the upload fails.
|
|
|
+- "-O", // Output reply to the file descriptor path.
|
|
|
+- status_fd_path,
|
|
|
+- nullptr,
|
|
|
++ kWgetBinary,
|
|
|
++ header_content_encoding,
|
|
|
++ header_content_type,
|
|
|
++ post_file,
|
|
|
++ g_upload_url,
|
|
|
++ "--timeout=10", // Set a timeout so we don't hang forever.
|
|
|
++ "--tries=1", // Don't retry if the upload fails.
|
|
|
++ "-O", // Output reply to the file descriptor path.
|
|
|
++ status_fd_path,
|
|
|
++ nullptr,
|
|
|
+ };
|
|
|
+ static const char msg[] = "Cannot upload crash dump: cannot exec "
|
|
|
+ "/usr/bin/wget\n";
|
|
|
+@@ -2037,6 +2041,10 @@ void InitCrashReporter(const std::string& process_type) {
|
|
|
+ #endif
|
|
|
+ process_type.empty();
|
|
|
+
|
|
|
++#if !defined(OS_CHROMEOS)
|
|
|
++ SetUploadURL(GetCrashReporterClient()->GetUploadUrl());
|
|
|
++#endif
|
|
|
++
|
|
|
+ if (is_browser_process) {
|
|
|
+ bool enable_breakpad = GetCrashReporterClient()->GetCollectStatsConsent() ||
|
|
|
+ GetCrashReporterClient()->IsRunningUnattended();
|
|
|
+diff --git a/components/crash/core/app/crash_reporter_client.cc b/components/crash/core/app/crash_reporter_client.cc
|
|
|
+index e778f68af30f8c071d1360d06b553cc957160c5b..0ef0f00e4320b2ab1584621df5b3b8081c65a788 100644
|
|
|
+--- a/components/crash/core/app/crash_reporter_client.cc
|
|
|
++++ b/components/crash/core/app/crash_reporter_client.cc
|
|
|
+@@ -4,6 +4,7 @@
|
|
|
+
|
|
|
+ #include "components/crash/core/app/crash_reporter_client.h"
|
|
|
+
|
|
|
++#include "build/branding_buildflags.h"
|
|
|
+ #include "build/build_config.h"
|
|
|
+
|
|
|
+ // On Windows don't use FilePath and logging.h.
|
|
|
+@@ -22,6 +23,10 @@ namespace {
|
|
|
+
|
|
|
+ CrashReporterClient* g_client = nullptr;
|
|
|
+
|
|
|
++#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && defined(OFFICIAL_BUILD)
|
|
|
++const char kDefaultUploadURL[] = "https://clients2.google.com/cr/report";
|
|
|
++#endif
|
|
|
++
|
|
|
+ } // namespace
|
|
|
+
|
|
|
+ void SetCrashReporterClient(CrashReporterClient* client) {
|
|
|
+@@ -196,6 +201,16 @@ void CrashReporterClient::GetSanitizationInformation(
|
|
|
+ }
|
|
|
+ #endif
|
|
|
+
|
|
|
++std::string CrashReporterClient::GetUploadUrl() {
|
|
|
++#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && defined(OFFICIAL_BUILD)
|
|
|
++ // Only allow the possibility of report upload in official builds. This
|
|
|
++ // crash server won't have symbols for any other build types.
|
|
|
++ return kDefaultUploadURL;
|
|
|
++#else
|
|
|
++ return std::string();
|
|
|
++#endif
|
|
|
++}
|
|
|
++
|
|
|
+ bool CrashReporterClient::ShouldMonitorCrashHandlerExpensively() {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+diff --git a/components/crash/core/app/crash_reporter_client.h b/components/crash/core/app/crash_reporter_client.h
|
|
|
+index 9cc78fc2584061d26fd1e83b3ebf5ada0a12c138..ad4bbbc5de3feb8441ba613009452c920d925820 100644
|
|
|
+--- a/components/crash/core/app/crash_reporter_client.h
|
|
|
++++ b/components/crash/core/app/crash_reporter_client.h
|
|
|
+@@ -194,6 +194,9 @@ class CrashReporterClient {
|
|
|
+ bool* sanitize_stacks);
|
|
|
+ #endif
|
|
|
+
|
|
|
++ // Returns the URL target for crash report uploads.
|
|
|
++ virtual std::string GetUploadUrl();
|
|
|
++
|
|
|
+ // This method should return true to configure a crash reporter capable of
|
|
|
+ // monitoring itself for its own crashes to do so, even if self-monitoring
|
|
|
+ // would be expensive. "Expensive" self-monitoring dedicates an additional
|
|
|
+diff --git a/components/crash/core/app/crashpad_linux.cc b/components/crash/core/app/crashpad_linux.cc
|
|
|
+index 5d31d0926cd1732bdd1808c232c18fc6ff550c05..56a79e28dece162210613c842df0a34aaa66f91c 100644
|
|
|
+--- a/components/crash/core/app/crashpad_linux.cc
|
|
|
++++ b/components/crash/core/app/crashpad_linux.cc
|
|
|
+@@ -120,9 +120,8 @@ base::FilePath PlatformCrashpadInitialization(
|
|
|
+ // to ChromeOS's /sbin/crash_reporter which in turn passes the dump to
|
|
|
+ // crash_sender which handles the upload.
|
|
|
+ std::string url;
|
|
|
+-#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && defined(OFFICIAL_BUILD) && \
|
|
|
+- !defined(OS_CHROMEOS)
|
|
|
+- url = "https://clients2.google.com/cr/report";
|
|
|
++#if !defined(OS_CHROMEOS)
|
|
|
++ url = crash_reporter_client->GetUploadUrl();
|
|
|
+ #else
|
|
|
+ url = std::string();
|
|
|
+ #endif
|
|
|
+diff --git a/components/crash/core/app/crashpad_mac.mm b/components/crash/core/app/crashpad_mac.mm
|
|
|
+index b579521d55860823722df2ee849f6b1628b3c950..c49d38082c41c7eb71ed2c701b06ed5b7eaa514a 100644
|
|
|
+--- a/components/crash/core/app/crashpad_mac.mm
|
|
|
++++ b/components/crash/core/app/crashpad_mac.mm
|
|
|
+@@ -133,13 +133,7 @@ base::FilePath PlatformCrashpadInitialization(
|
|
|
+ crash_reporter_client->GetCrashDumpLocation(&database_path);
|
|
|
+ crash_reporter_client->GetCrashMetricsLocation(&metrics_path);
|
|
|
+
|
|
|
+-#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && defined(OFFICIAL_BUILD)
|
|
|
+- // Only allow the possibility of report upload in official builds. This
|
|
|
+- // crash server won't have symbols for any other build types.
|
|
|
+- std::string url = "https://clients2.google.com/cr/report";
|
|
|
+-#else
|
|
|
+- std::string url;
|
|
|
+-#endif
|
|
|
++ std::string url = crash_reporter_client->GetUploadUrl();
|
|
|
+
|
|
|
+ std::vector<std::string> arguments;
|
|
|
+
|
|
|
+diff --git a/components/crash/core/app/crashpad_win.cc b/components/crash/core/app/crashpad_win.cc
|
|
|
+index 669f5bea844d75f0e5c34b58994f4cfb8e856af0..c199b467ffeb007f3098ccde6879fbd71e9ec9fd 100644
|
|
|
+--- a/components/crash/core/app/crashpad_win.cc
|
|
|
++++ b/components/crash/core/app/crashpad_win.cc
|
|
|
+@@ -85,11 +85,7 @@ base::FilePath PlatformCrashpadInitialization(
|
|
|
+ std::map<std::string, std::string> process_annotations;
|
|
|
+ GetPlatformCrashpadAnnotations(&process_annotations);
|
|
|
+
|
|
|
+-#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
|
|
+- std::string url = "https://clients2.google.com/cr/report";
|
|
|
+-#else
|
|
|
+- std::string url;
|
|
|
+-#endif
|
|
|
++ std::string url = crash_reporter_client->GetUploadUrl();
|
|
|
+
|
|
|
+ // Allow the crash server to be overridden for testing. If the variable
|
|
|
+ // isn't present in the environment then the default URL will remain.
|