Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/common/crash_reporter/aw_microdump_crash_reporter.h" | 5 #include "android_webview/common/crash_reporter/aw_microdump_crash_reporter.h" |
| 6 | 6 |
| 7 #include "android_webview/common/aw_descriptors.h" | 7 #include "android_webview/common/aw_descriptors.h" |
| 8 #include "android_webview/common/aw_paths.h" | 8 #include "android_webview/common/aw_paths.h" |
| 9 #include "android_webview/common/aw_version_info_values.h" | 9 #include "android_webview/common/aw_version_info_values.h" |
| 10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
| 11 #include "base/base_paths_android.h" | 11 #include "base/base_paths_android.h" |
| 12 #include "base/debug/dump_without_crashing.h" | 12 #include "base/debug/dump_without_crashing.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/scoped_native_library.h" | 16 #include "base/scoped_native_library.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "components/crash/content/app/breakpad_linux.h" | 19 #include "components/crash/content/app/breakpad_linux.h" |
| 20 #include "components/crash/content/app/crash_reporter_client.h" | 20 #include "components/crash/content/app/crash_reporter_client.h" |
| 21 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 22 | 22 |
| 23 namespace android_webview { | 23 namespace android_webview { |
| 24 namespace crash_reporter { | 24 namespace crash_reporter { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 #if !defined(COMPONENT_BUILD) | |
| 29 void PrincipalMappingMarker() {} | |
| 30 #endif | |
| 31 | |
| 28 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient { | 32 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient { |
| 29 public: | 33 public: |
| 30 AwCrashReporterClient() | 34 AwCrashReporterClient() |
| 31 : dump_fd_(kAndroidMinidumpDescriptor), crash_signal_fd_(-1) {} | 35 : dump_fd_(kAndroidMinidumpDescriptor), crash_signal_fd_(-1) {} |
| 32 | 36 |
| 33 // Does not use lock, can only be called immediately after creation. | 37 // Does not use lock, can only be called immediately after creation. |
| 34 void set_crash_signal_fd(int fd) { crash_signal_fd_ = fd; } | 38 void set_crash_signal_fd(int fd) { crash_signal_fd_ = fd; } |
| 35 | 39 |
| 36 // crash_reporter::CrashReporterClient implementation. | 40 // crash_reporter::CrashReporterClient implementation. |
| 37 bool IsRunningUnattended() override { return false; } | 41 bool IsRunningUnattended() override { return false; } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 LOG(WARNING) << "Can't use breakpad to handle WebView crashes"; | 146 LOG(WARNING) << "Can't use breakpad to handle WebView crashes"; |
| 143 return; | 147 return; |
| 144 } | 148 } |
| 145 #endif | 149 #endif |
| 146 | 150 |
| 147 AwCrashReporterClient* client = g_crash_reporter_client.Pointer(); | 151 AwCrashReporterClient* client = g_crash_reporter_client.Pointer(); |
| 148 if (process_type == switches::kRendererProcess && crash_signal_fd != -1) { | 152 if (process_type == switches::kRendererProcess && crash_signal_fd != -1) { |
| 149 client->set_crash_signal_fd(crash_signal_fd); | 153 client->set_crash_signal_fd(crash_signal_fd); |
| 150 } | 154 } |
| 151 ::crash_reporter::SetCrashReporterClient(client); | 155 ::crash_reporter::SetCrashReporterClient(client); |
| 156 breakpad::SetShouldSanitizeDumps(true); | |
| 157 #if !defined(COMPONENT_BUILD) | |
| 158 breakpad::SetSkipDumpIfPrincipalMappingNotReferenced( | |
| 159 reinterpret_cast<uintptr_t>(&PrincipalMappingMarker)); | |
|
Robert Sesek
2017/02/09 22:21:54
I'd still probably just use EnableCrashReporter.
Tobias Sargeant
2017/02/10 13:24:05
Done. Didn't also realise when moving the call to
| |
| 160 #endif | |
| 152 | 161 |
| 153 bool is_browser_process = | 162 bool is_browser_process = |
| 154 process_type.empty() || | 163 process_type.empty() || |
| 155 process_type == breakpad::kWebViewSingleProcessType || | 164 process_type == breakpad::kWebViewSingleProcessType || |
| 156 process_type == breakpad::kBrowserProcessType; | 165 process_type == breakpad::kBrowserProcessType; |
| 157 if (is_browser_process) { | 166 if (is_browser_process) { |
| 158 breakpad::InitCrashReporter(""); | 167 breakpad::InitCrashReporter(""); |
| 159 } else { | 168 } else { |
| 160 breakpad::InitNonBrowserCrashReporterForAndroid(process_type); | 169 breakpad::InitNonBrowserCrashReporterForAndroid(process_type); |
| 161 } | 170 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 178 bool IsCrashReporterEnabled() { | 187 bool IsCrashReporterEnabled() { |
| 179 return breakpad::IsCrashReporterEnabled(); | 188 return breakpad::IsCrashReporterEnabled(); |
| 180 } | 189 } |
| 181 | 190 |
| 182 void SuppressDumpGeneration() { | 191 void SuppressDumpGeneration() { |
| 183 breakpad::SuppressDumpGeneration(); | 192 breakpad::SuppressDumpGeneration(); |
| 184 } | 193 } |
| 185 | 194 |
| 186 } // namespace crash_reporter | 195 } // namespace crash_reporter |
| 187 } // namespace android_webview | 196 } // namespace android_webview |
| OLD | NEW |