| 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/crash_reporter/aw_microdump_crash_reporter.h" | 5 #include "android_webview/crash_reporter/aw_microdump_crash_reporter.h" |
| 6 | 6 |
| 7 #include "android_webview/common/aw_version_info_values.h" | 7 #include "android_webview/common/aw_version_info_values.h" |
| 8 #include "base/debug/dump_without_crashing.h" | 8 #include "base/debug/dump_without_crashing.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/scoped_native_library.h" | 11 #include "base/scoped_native_library.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "components/crash/content/app/breakpad_linux.h" | 14 #include "components/crash/content/app/breakpad_linux.h" |
| 15 #include "components/crash/content/app/crash_reporter_client.h" | 15 #include "components/crash/content/app/crash_reporter_client.h" |
| 16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 17 | 17 |
| 18 namespace android_webview { | 18 namespace android_webview { |
| 19 namespace crash_reporter { | 19 namespace crash_reporter { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient { | 23 class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient { |
| 24 public: | 24 public: |
| 25 AwCrashReporterClient() : dump_fd_(-1) {} | 25 AwCrashReporterClient() : dump_fd_(-1), crash_signal_fd_(-1) {} |
| 26 | 26 |
| 27 // Does not use lock, can only be called immediately after creation. | 27 // Does not use lock, can only be called immediately after creation. |
| 28 void set_crash_signal_fd(int fd) { dump_fd_ = fd; } | 28 void set_crash_signal_fd(int fd) { crash_signal_fd_ = fd; } |
| 29 | 29 |
| 30 // crash_reporter::CrashReporterClient implementation. | 30 // crash_reporter::CrashReporterClient implementation. |
| 31 bool IsRunningUnattended() override { return false; } | 31 bool IsRunningUnattended() override { return false; } |
| 32 bool GetCollectStatsConsent() override { return false; } | 32 bool GetCollectStatsConsent() override { return false; } |
| 33 | 33 |
| 34 void GetProductNameAndVersion(const char** product_name, | 34 void GetProductNameAndVersion(const char** product_name, |
| 35 const char** version) override { | 35 const char** version) override { |
| 36 *product_name = "WebView"; | 36 *product_name = "WebView"; |
| 37 *version = PRODUCT_VERSION; | 37 *version = PRODUCT_VERSION; |
| 38 } | 38 } |
| 39 // Microdumps are always enabled in WebView builds, conversely to what happens | 39 // Microdumps are always enabled in WebView builds, conversely to what happens |
| 40 // in the case of the other Chrome for Android builds (where they are enabled | 40 // in the case of the other Chrome for Android builds (where they are enabled |
| 41 // only when NO_UNWIND_TABLES == 1). | 41 // only when NO_UNWIND_TABLES == 1). |
| 42 bool ShouldEnableBreakpadMicrodumps() override { return true; } | 42 bool ShouldEnableBreakpadMicrodumps() override { return true; } |
| 43 | 43 |
| 44 int GetAndroidMinidumpDescriptor() override { return dump_fd_; } | 44 int GetAndroidMinidumpDescriptor() override { return dump_fd_; } |
| 45 int GetAndroidCrashSignalFD() override { return crash_signal_fd_; } |
| 45 | 46 |
| 46 bool DumpWithoutCrashingToFd(int fd) { | 47 bool DumpWithoutCrashingToFd(int fd) { |
| 47 DCHECK(dump_fd_ == -1); | 48 DCHECK(dump_fd_ == -1); |
| 48 base::AutoLock lock(dump_lock_); | 49 base::AutoLock lock(dump_lock_); |
| 49 dump_fd_ = fd; | 50 dump_fd_ = fd; |
| 50 base::debug::DumpWithoutCrashing(); | 51 base::debug::DumpWithoutCrashing(); |
| 51 dump_fd_ = -1; | 52 dump_fd_ = -1; |
| 52 return true; | 53 return true; |
| 53 } | 54 } |
| 54 | 55 |
| 55 private: | 56 private: |
| 56 int dump_fd_; | 57 int dump_fd_; |
| 58 int crash_signal_fd_; |
| 57 base::Lock dump_lock_; | 59 base::Lock dump_lock_; |
| 58 DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient); | 60 DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient); |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 base::LazyInstance<AwCrashReporterClient>::Leaky g_crash_reporter_client = | 63 base::LazyInstance<AwCrashReporterClient>::Leaky g_crash_reporter_client = |
| 62 LAZY_INSTANCE_INITIALIZER; | 64 LAZY_INSTANCE_INITIALIZER; |
| 63 | 65 |
| 64 bool g_enabled = false; | 66 bool g_enabled = false; |
| 65 | 67 |
| 66 #if defined(ARCH_CPU_X86_FAMILY) | 68 #if defined(ARCH_CPU_X86_FAMILY) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 const std::string& gpu_fingerprint) { | 144 const std::string& gpu_fingerprint) { |
| 143 breakpad::AddGpuFingerprintToMicrodumpCrashHandler(gpu_fingerprint); | 145 breakpad::AddGpuFingerprintToMicrodumpCrashHandler(gpu_fingerprint); |
| 144 } | 146 } |
| 145 | 147 |
| 146 bool DumpWithoutCrashingToFd(int fd) { | 148 bool DumpWithoutCrashingToFd(int fd) { |
| 147 return g_crash_reporter_client.Pointer()->DumpWithoutCrashingToFd(fd); | 149 return g_crash_reporter_client.Pointer()->DumpWithoutCrashingToFd(fd); |
| 148 } | 150 } |
| 149 | 151 |
| 150 } // namespace crash_reporter | 152 } // namespace crash_reporter |
| 151 } // namespace android_webview | 153 } // namespace android_webview |
| OLD | NEW |