0

AwDebug: write a phony dump if crashpad isn't enabled

Change-Id: Ied073362bbed4a7d7504db1d076827e641dc3657
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1542957
Reviewed-by: Richard Coles <torne@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#645408}
This commit is contained in:
Joshua Peraza
2019-03-28 18:22:31 +00:00
committed by Commit Bot
parent ec11fe8159
commit fdc73015b5
3 changed files with 20 additions and 5 deletions

@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string.h>
#include <memory>
#include "android_webview/common/aw_channel.h"
#include "android_webview/common/crash_reporter/aw_crash_reporter_client.h"
#include "android_webview/common/crash_reporter/crash_keys.h"
@ -24,8 +28,6 @@
#include "third_party/crashpad/crashpad/util/net/http_body.h"
#include "third_party/crashpad/crashpad/util/net/http_multipart_builder.h"
#include <memory>
using base::android::ConvertJavaStringToUTF16;
using base::android::ConvertUTF8ToJavaString;
using base::android::JavaParamRef;
@ -138,6 +140,12 @@ static jboolean JNI_AwDebug_DumpWithoutCrashing(
if (!target.IsValid())
return false;
if (!CrashReporterEnabled()) {
static constexpr char kMessage[] = "WebView isn't initialized";
return static_cast<size_t>(target.WriteAtCurrentPos(
kMessage, strlen(kMessage))) == strlen(kMessage);
}
AwDebugCrashReporterClient client;
base::FilePath database_path;
if (!client.GetCrashDumpLocation(&database_path)) {

@ -151,15 +151,15 @@ bool SafeToUseSignalHandler() {
}
#endif
bool g_enabled;
} // namespace
void EnableCrashReporter(const std::string& process_type) {
static bool enabled;
if (enabled) {
if (g_enabled) {
NOTREACHED() << "EnableCrashReporter called more than once";
return;
}
enabled = true;
#if defined(ARCH_CPU_X86_FAMILY)
if (!SafeToUseSignalHandler()) {
@ -171,6 +171,11 @@ void EnableCrashReporter(const std::string& process_type) {
AwCrashReporterClient* client = g_crash_reporter_client.Pointer();
crash_reporter::SetCrashReporterClient(client);
crash_reporter::InitializeCrashpad(process_type.empty(), process_type);
g_enabled = true;
}
bool CrashReporterEnabled() {
return g_enabled;
}
} // namespace android_webview

@ -11,6 +11,8 @@ namespace android_webview {
void EnableCrashReporter(const std::string& process_type);
bool CrashReporterEnabled();
} // namespace android_webview
#endif // ANDROID_WEBVIEW_COMMON_CRASH_REPORTER_AW_CRASH_REPORTER_CLIENT_H_