Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / android_webview / crash_reporter / aw_microdump_crash_reporter.cc
blob016288a9c672769c3e846a1a3c6ff3327c8addaa
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "android_webview/crash_reporter/aw_microdump_crash_reporter.h"
7 #include "base/lazy_instance.h"
8 #include "build/build_config.h"
9 #include "components/crash/app/breakpad_linux.h"
10 #include "components/crash/app/crash_reporter_client.h"
12 namespace android_webview {
13 namespace crash_reporter {
15 namespace {
17 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient {
18 public:
19 AwCrashReporterClient() {}
21 // crash_reporter::CrashReporterClient implementation.
22 bool IsRunningUnattended() override { return false; }
23 bool GetCollectStatsConsent() override { return false; }
25 // Microdumps are always enabled in WebView builds, conversely to what happens
26 // in the case of the other Chrome for Android builds (where they are enabled
27 // only when NO_UNWIND_TABLES == 1).
28 bool ShouldEnableBreakpadMicrodumps() override { return true; }
30 private:
31 DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient);
34 base::LazyInstance<AwCrashReporterClient>::Leaky g_crash_reporter_client =
35 LAZY_INSTANCE_INITIALIZER;
37 bool g_enabled = false;
39 } // namespace
41 void EnableMicrodumpCrashReporter() {
42 #if defined(ARCH_CPU_X86_FAMILY)
43 // Don't install signal handler on X86/64 because this breaks binary
44 // translators that handle SIGSEGV in userspace and get chained after our
45 // handler. See crbug.com/477444
46 return;
47 #endif
49 if (g_enabled) {
50 NOTREACHED() << "EnableMicrodumpCrashReporter called more than once";
51 return;
54 ::crash_reporter::SetCrashReporterClient(g_crash_reporter_client.Pointer());
56 // |process_type| is not really relevant here, as long as it not empty.
57 breakpad::InitNonBrowserCrashReporterForAndroid("webview" /* process_type */);
58 g_enabled = true;
61 } // namespace crash_reporter
62 } // namespace android_webview