Commit 0c0fc42d authored by Joshua Peraza's avatar Joshua Peraza Committed by Commit Bot

Implement CrashReporterClient methods for Crashpad

This new implementation of GetProductNameAndVersion() will replace the
existing one in the transition to Crashpad.

GetSanitizationInformation() (for webview) will replace
GetCrashKeysWhitelist() and the SanitizationInfo struct passed during
crash reporter initialization.

These new methods are currently unused.

Bug: crashpad:30
Change-Id: Ic60d17cb3af8b4e7997009c23a44fcc8b94915a7
Reviewed-on: https://chromium-review.googlesource.com/1142511Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578843}
parent 1e48d97a
......@@ -645,6 +645,8 @@ source_set("common") {
"browser/tracing/aw_tracing_delegate.h",
"common/android_webview_message_generator.cc",
"common/android_webview_message_generator.h",
"common/aw_channel.cc",
"common/aw_channel.h",
"common/aw_content_client.cc",
"common/aw_content_client.h",
"common/aw_descriptors.h",
......
......@@ -4,11 +4,10 @@
#include "android_webview/browser/aw_variations_service_client.h"
#include "android_webview/common/aw_channel.h"
#include "base/bind.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "components/version_info/android/channel_getter.h"
#include "components/version_info/version_info.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
using version_info::Channel;
......@@ -49,13 +48,7 @@ AwVariationsServiceClient::GetNetworkTimeTracker() {
}
Channel AwVariationsServiceClient::GetChannel() {
Channel channel = version_info::GetChannel();
// There are separate Monochrome APKs built for each channel, but only one
// stand-alone WebView APK for all channels, so stand-alone WebView has
// channel "unknown". Pretend stand-alone WebView is always "stable" for the
// purpose of variations. This simplifies experiment design, since stand-alone
// WebView need not be considered separately when choosing channels.
return channel == Channel::UNKNOWN ? Channel::STABLE : channel;
return android_webview::GetChannel();
}
bool AwVariationsServiceClient::GetSupportsPermanentConsistency() {
......
// Copyright 2018 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/common/aw_channel.h"
#include "components/version_info/android/channel_getter.h"
namespace android_webview {
using version_info::Channel;
Channel GetChannel() {
Channel channel = version_info::GetChannel();
// There are separate Monochrome APKs built for each channel, but only one
// stand-alone WebView APK for all channels, so stand-alone WebView has
// channel "unknown". Pretend stand-alone WebView is always "stable" for the
// purpose of variations. This simplifies experiment design, since stand-alone
// WebView need not be considered separately when choosing channels.
return channel == Channel::UNKNOWN ? Channel::STABLE : channel;
}
} // namespace android_webview
// Copyright 2018 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_COMMON_AW_CHANNEL_H_
#define ANDROID_WEBVIEW_COMMON_AW_CHANNEL_H_
#include "components/version_info/version_info.h"
namespace android_webview {
version_info::Channel GetChannel();
} // namespace android_webview
#endif // ANDROID_WEBVIEW_COMMON_AW_CHANNEL_H_
......@@ -6,6 +6,7 @@
#include <random>
#include "android_webview/common/aw_channel.h"
#include "android_webview/common/aw_descriptors.h"
#include "android_webview/common/aw_paths.h"
#include "android_webview/common/crash_reporter/crash_keys.h"
......@@ -22,6 +23,7 @@
#include "build/build_config.h"
#include "components/crash/content/app/breakpad_linux.h"
#include "components/crash/content/app/crash_reporter_client.h"
#include "components/version_info/version_info.h"
#include "components/version_info/version_info_values.h"
#include "content/public/common/content_switches.h"
......@@ -66,6 +68,13 @@ class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient {
*product_name = "AndroidWebView";
*version = PRODUCT_VERSION;
}
void GetProductNameAndVersion(std::string* product_name,
std::string* version,
std::string* channel) override {
*product_name = "AndroidWebView";
*version = PRODUCT_VERSION;
*channel = version_info::GetChannelString(android_webview::GetChannel());
}
// 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).
......@@ -85,6 +94,18 @@ class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient {
return base::PathService::Get(android_webview::DIR_CRASH_DUMPS, crash_dir);
}
void GetSanitizationInformation(const char* const** annotations_whitelist,
void** target_module,
bool* sanitize_stacks) override {
*annotations_whitelist = crash_keys::kWebViewCrashKeyWhiteList;
#if defined(COMPONENT_BUILD)
*target_module = nullptr;
#else
*target_module = reinterpret_cast<void*>(&EnableCrashReporter);
#endif
*sanitize_stacks = true;
}
private:
int dump_fd_;
int crash_signal_fd_;
......
......@@ -12,6 +12,7 @@
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_result_codes.h"
......@@ -72,6 +73,18 @@ void ChromeCrashReporterClient::GetProductNameAndVersion(
*version = PRODUCT_VERSION;
}
void ChromeCrashReporterClient::GetProductNameAndVersion(
std::string* product_name,
std::string* version,
std::string* channel) {
const char* c_product_name;
const char* c_version;
GetProductNameAndVersion(&c_product_name, &c_version);
*product_name = c_product_name;
*version = c_version;
*channel = chrome::GetChannelName();
}
base::FilePath ChromeCrashReporterClient::GetReporterLogFilename() {
return base::FilePath(CrashUploadList::kReporterLogFilename);
}
......
......@@ -28,6 +28,9 @@ class ChromeCrashReporterClient : public crash_reporter::CrashReporterClient {
#if defined(OS_POSIX) && !defined(OS_MACOSX)
void GetProductNameAndVersion(const char** product_name,
const char** version) override;
void GetProductNameAndVersion(std::string* product_name,
std::string* version,
std::string* channel) override;
base::FilePath GetReporterLogFilename() override;
#endif
......
......@@ -61,6 +61,7 @@ cast_source_set("cast_crash_client") {
if (is_android) {
deps += [
"//chromecast/base:cast_sys_info",
"//chromecast/base:cast_version",
"//chromecast/browser:jni_headers",
"//third_party/breakpad:client",
......
......@@ -8,6 +8,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "chromecast/base/cast_sys_info_android.h"
#include "chromecast/base/chromecast_config_android.h"
#include "chromecast/base/version.h"
#include "chromecast/common/global_descriptors.h"
......@@ -34,6 +35,20 @@ void CastCrashReporterClientAndroid::GetProductNameAndVersion(
"." CAST_BUILD_REVISION;
}
void CastCrashReporterClientAndroid::GetProductNameAndVersion(
std::string* product_name,
std::string* version,
std::string* channel) {
*product_name = "media_shell";
*version = PRODUCT_VERSION
#if CAST_IS_DEBUG_BUILD()
".debug"
#endif
"." CAST_BUILD_REVISION;
CastSysInfoAndroid sys_info;
*channel = sys_info.GetSystemReleaseChannel();
}
base::FilePath CastCrashReporterClientAndroid::GetReporterLogFilename() {
return base::FilePath(FILE_PATH_LITERAL("uploads.log"));
}
......
......@@ -25,6 +25,9 @@ class CastCrashReporterClientAndroid
// crash_reporter::CrashReporterClient implementation:
void GetProductNameAndVersion(const char** product_name,
const char** version) override;
void GetProductNameAndVersion(std::string* product_name,
std::string* version,
std::string* channel) override;
base::FilePath GetReporterLogFilename() override;
bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
int GetAndroidMinidumpDescriptor() override;
......
......@@ -46,6 +46,15 @@ void ShellCrashReporterClient::GetProductNameAndVersion(
*version = CONTENT_SHELL_VERSION;
}
void ShellCrashReporterClient::GetProductNameAndVersion(
std::string* product_name,
std::string* version,
std::string* channel) {
*product_name = "content_shell";
*version = CONTENT_SHELL_VERSION;
*channel = "";
}
base::FilePath ShellCrashReporterClient::GetReporterLogFilename() {
return base::FilePath(FILE_PATH_LITERAL("uploads.log"));
}
......
......@@ -32,7 +32,9 @@ class ShellCrashReporterClient : public crash_reporter::CrashReporterClient {
// in the crash report.
void GetProductNameAndVersion(const char** product_name,
const char** version) override;
void GetProductNameAndVersion(std::string* product_name,
std::string* version,
std::string* channel) override;
base::FilePath GetReporterLogFilename() override;
#endif
......
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