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 "components/crash/app/breakpad_linux.h"
9 #include "components/crash/app/crash_reporter_client.h"
11 namespace android_webview
{
12 namespace crash_reporter
{
16 class AwCrashReporterClient
: public ::crash_reporter::CrashReporterClient
{
18 AwCrashReporterClient() {}
20 // crash_reporter::CrashReporterClient implementation.
21 bool IsRunningUnattended() override
{ return false; }
22 bool GetCollectStatsConsent() override
{ return false; }
24 // Microdumps are always enabled in WebView builds, conversely to what happens
25 // in the case of the other Chrome for Android builds (where they are enabled
26 // only when NO_UNWIND_TABLES == 1).
27 bool ShouldEnableBreakpadMicrodumps() override
{ return true; }
30 DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient
);
33 base::LazyInstance
<AwCrashReporterClient
>::Leaky g_crash_reporter_client
=
34 LAZY_INSTANCE_INITIALIZER
;
36 bool g_enabled
= false;
40 void EnableMicrodumpCrashReporter() {
42 NOTREACHED() << "EnableMicrodumpCrashReporter called more than once";
46 ::crash_reporter::SetCrashReporterClient(g_crash_reporter_client
.Pointer());
48 // |process_type| is not really relevant here, as long as it not empty.
49 breakpad::InitNonBrowserCrashReporterForAndroid("webview" /* process_type */);
53 } // namespace crash_reporter
54 } // namespace android_webview