Enable mirroring option in unified desktop mode
[chromium-blink-merge.git] / android_webview / crash_reporter / aw_microdump_crash_reporter.cc
blobebb4fa00cd5e23995a6419e519551282f66808d4
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 "android_webview/common/aw_version_info_values.h"
8 #include "base/lazy_instance.h"
9 #include "build/build_config.h"
10 #include "components/crash/app/breakpad_linux.h"
11 #include "components/crash/app/crash_reporter_client.h"
13 namespace android_webview {
14 namespace crash_reporter {
16 namespace {
18 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient {
19 public:
20 AwCrashReporterClient() {}
22 // crash_reporter::CrashReporterClient implementation.
23 bool IsRunningUnattended() override { return false; }
24 bool GetCollectStatsConsent() override { return false; }
26 void GetProductNameAndVersion(const char** product_name,
27 const char** version) override {
28 *product_name = "WebView";
29 *version = PRODUCT_VERSION;
31 // Microdumps are always enabled in WebView builds, conversely to what happens
32 // in the case of the other Chrome for Android builds (where they are enabled
33 // only when NO_UNWIND_TABLES == 1).
34 bool ShouldEnableBreakpadMicrodumps() override { return true; }
36 private:
37 DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient);
40 base::LazyInstance<AwCrashReporterClient>::Leaky g_crash_reporter_client =
41 LAZY_INSTANCE_INITIALIZER;
43 bool g_enabled = false;
45 } // namespace
47 void EnableMicrodumpCrashReporter() {
48 #if defined(ARCH_CPU_X86_FAMILY)
49 // Don't install signal handler on X86/64 because this breaks binary
50 // translators that handle SIGSEGV in userspace and get chained after our
51 // handler. See crbug.com/477444
52 return;
53 #endif
55 if (g_enabled) {
56 NOTREACHED() << "EnableMicrodumpCrashReporter called more than once";
57 return;
60 ::crash_reporter::SetCrashReporterClient(g_crash_reporter_client.Pointer());
62 // |process_type| is not really relevant here, as long as it not empty.
63 breakpad::InitNonBrowserCrashReporterForAndroid("webview" /* process_type */);
64 g_enabled = true;
67 } // namespace crash_reporter
68 } // namespace android_webview