ProfilePolicyConnectorFactory: Refactoring from Profile to BrowserContext.
[chromium-blink-merge.git] / android_webview / crash_reporter / aw_microdump_crash_reporter.cc
blob490cd9b7de7df929be54e441b5d5d16d774c861b
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 {
14 namespace {
16 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient {
17 public:
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; }
29 private:
30 DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient);
33 base::LazyInstance<AwCrashReporterClient>::Leaky g_crash_reporter_client =
34 LAZY_INSTANCE_INITIALIZER;
36 bool g_enabled = false;
38 } // namespace
40 void EnableMicrodumpCrashReporter() {
41 if (g_enabled) {
42 NOTREACHED() << "EnableMicrodumpCrashReporter called more than once";
43 return;
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 */);
50 g_enabled = true;
53 } // namespace crash_reporter
54 } // namespace android_webview