summaryrefslogtreecommitdiffstats
path: root/android_webview/crash_reporter
diff options
context:
space:
mode:
Diffstat (limited to 'android_webview/crash_reporter')
-rw-r--r--android_webview/crash_reporter/DEPS3
-rw-r--r--android_webview/crash_reporter/aw_microdump_crash_reporter.cc54
-rw-r--r--android_webview/crash_reporter/aw_microdump_crash_reporter.h16
-rw-r--r--android_webview/crash_reporter/aw_microdump_crash_reporter_disabled_in_android_builds.cc21
4 files changed, 94 insertions, 0 deletions
diff --git a/android_webview/crash_reporter/DEPS b/android_webview/crash_reporter/DEPS
new file mode 100644
index 0000000..99162b4
--- /dev/null
+++ b/android_webview/crash_reporter/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+components/crash",
+]
diff --git a/android_webview/crash_reporter/aw_microdump_crash_reporter.cc b/android_webview/crash_reporter/aw_microdump_crash_reporter.cc
new file mode 100644
index 0000000..490cd9b
--- /dev/null
+++ b/android_webview/crash_reporter/aw_microdump_crash_reporter.cc
@@ -0,0 +1,54 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/crash_reporter/aw_microdump_crash_reporter.h"
+
+#include "base/lazy_instance.h"
+#include "components/crash/app/breakpad_linux.h"
+#include "components/crash/app/crash_reporter_client.h"
+
+namespace android_webview {
+namespace crash_reporter {
+
+namespace {
+
+class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient {
+ public:
+ AwCrashReporterClient() {}
+
+ // crash_reporter::CrashReporterClient implementation.
+ bool IsRunningUnattended() override { return false; }
+ bool GetCollectStatsConsent() override { return false; }
+
+ // Microdumps are always enabled in WebView builds, conversely to what happens
+ // in the case of the other Chrome for Android builds (where they are enabled
+ // only when NO_UNWIND_TABLES == 1).
+ bool ShouldEnableBreakpadMicrodumps() override { return true; }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient);
+};
+
+base::LazyInstance<AwCrashReporterClient>::Leaky g_crash_reporter_client =
+ LAZY_INSTANCE_INITIALIZER;
+
+bool g_enabled = false;
+
+} // namespace
+
+void EnableMicrodumpCrashReporter() {
+ if (g_enabled) {
+ NOTREACHED() << "EnableMicrodumpCrashReporter called more than once";
+ return;
+ }
+
+ ::crash_reporter::SetCrashReporterClient(g_crash_reporter_client.Pointer());
+
+ // |process_type| is not really relevant here, as long as it not empty.
+ breakpad::InitNonBrowserCrashReporterForAndroid("webview" /* process_type */);
+ g_enabled = true;
+}
+
+} // namespace crash_reporter
+} // namespace android_webview
diff --git a/android_webview/crash_reporter/aw_microdump_crash_reporter.h b/android_webview/crash_reporter/aw_microdump_crash_reporter.h
new file mode 100644
index 0000000..5176b31
--- /dev/null
+++ b/android_webview/crash_reporter/aw_microdump_crash_reporter.h
@@ -0,0 +1,16 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ANDROID_WEBVIEW_CRASH_REPORTER_AW_MICRODUMP_CRASH_REPORTER_H_
+#define ANDROID_WEBVIEW_CRASH_REPORTER_AW_MICRODUMP_CRASH_REPORTER_H_
+
+namespace android_webview {
+namespace crash_reporter {
+
+void EnableMicrodumpCrashReporter();
+
+} // namespace crash_reporter
+} // namespace android_webview
+
+#endif // ANDROID_WEBVIEW_CRASH_REPORTER_AW_MICRODUMP_CRASH_REPORTER_H_
diff --git a/android_webview/crash_reporter/aw_microdump_crash_reporter_disabled_in_android_builds.cc b/android_webview/crash_reporter/aw_microdump_crash_reporter_disabled_in_android_builds.cc
new file mode 100644
index 0000000..d5c6e7b
--- /dev/null
+++ b/android_webview/crash_reporter/aw_microdump_crash_reporter_disabled_in_android_builds.cc
@@ -0,0 +1,21 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/crash_reporter/aw_microdump_crash_reporter.h"
+
+// TODO(primiano): remove this once Android builds of WebView are deprecated.
+// This translation unit is a no-op fallback for AwCrashReporter. This is built
+// only when building in the Android tree.
+// The rationale of this hack is to avoid the cost of maintaining breakpad in
+// the Android tree, as the WebView build in Android itself is going to be
+// deprecated soon (crbug.com/440792).
+
+namespace android_webview {
+namespace crash_reporter {
+
+void EnableMicrodumpCrashReporter() {
+}
+
+} // namespace crash_reporter
+} // namespace android_webview