Commit 2d3f4b2a authored by primiano's avatar primiano Committed by Commit bot

[android-webview] Enable breakpad microdump crash reporting

This CL:
 - Pulls in the dependencies required to build breakpad and the
   crash component.
 - Introduces a crash reporter for WebView which unconditionally
   enables microdumps (but not minidump uploads).
 - Introduces a fallback no-op implementation which avoids the burden
   of importing and supporting breakpad in the internal Android builds
   (which are going to be deprecated soon).

Impact of this change on the WebView APK size:
  Before the change: 25700337 bytes
  After the change:  25720974 bytes
  Delta:                20637 bytes

Impact of this change on the uncompressed libwebviewchromium.so lib:
  Before the change: 28547980 bytes
  After the change:  28576844 bytes
  Delta:                28864 bytes

BUG=410294, 456494
TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/902093003

Cr-Commit-Position: refs/heads/master@{#315357}
parent 93ae8193
...@@ -303,6 +303,7 @@ ...@@ -303,6 +303,7 @@
'common/render_view_messages.h', 'common/render_view_messages.h',
'common/url_constants.cc', 'common/url_constants.cc',
'common/url_constants.h', 'common/url_constants.h',
'crash_reporter/aw_microdump_crash_reporter.h',
'lib/aw_browser_dependency_factory_impl.cc', 'lib/aw_browser_dependency_factory_impl.cc',
'lib/aw_browser_dependency_factory_impl.h', 'lib/aw_browser_dependency_factory_impl.h',
'lib/main/aw_main_delegate.cc', 'lib/main/aw_main_delegate.cc',
...@@ -327,6 +328,23 @@ ...@@ -327,6 +328,23 @@
'renderer/print_render_frame_observer.cc', 'renderer/print_render_frame_observer.cc',
'renderer/print_render_frame_observer.h', 'renderer/print_render_frame_observer.h',
], ],
# TODO(primiano): remove the *_disabled_in_android_builds fallback and
# merge this with the target once android_webview_build goes away.
'conditions': [
['android_webview_build==0', {
'dependencies': [
'../components/components.gyp:breakpad_host',
'../components/components.gyp:crash_component',
],
'sources': [
'crash_reporter/aw_microdump_crash_reporter.cc',
],
}, { # android_webview_build==1
'sources': [
'crash_reporter/aw_microdump_crash_reporter_disabled_in_android_builds.cc',
],
}],
],
}, },
{ {
'target_name': 'libwebviewchromium', 'target_name': 'libwebviewchromium',
......
include_rules = [
"+components/crash",
]
// 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
// 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_
// 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
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "android_webview/browser/aw_content_browser_client.h" #include "android_webview/browser/aw_content_browser_client.h"
#include "android_webview/browser/browser_view_renderer.h" #include "android_webview/browser/browser_view_renderer.h"
#include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h" #include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h"
#include "android_webview/crash_reporter/aw_microdump_crash_reporter.h"
#include "android_webview/lib/aw_browser_dependency_factory_impl.h" #include "android_webview/lib/aw_browser_dependency_factory_impl.h"
#include "android_webview/native/aw_assets.h" #include "android_webview/native/aw_assets.h"
#include "android_webview/native/aw_media_url_interceptor.h" #include "android_webview/native/aw_media_url_interceptor.h"
...@@ -123,6 +124,8 @@ void AwMainDelegate::PreSandboxStartup() { ...@@ -123,6 +124,8 @@ void AwMainDelegate::PreSandboxStartup() {
// cpu_brand info. // cpu_brand info.
base::CPU cpu_info; base::CPU cpu_info;
#endif #endif
crash_reporter::EnableMicrodumpCrashReporter();
} }
void AwMainDelegate::SandboxInitialized(const std::string& process_type) { void AwMainDelegate::SandboxInitialized(const std::string& process_type) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment