| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/app/mash/mash_crash_reporter_client.h" |
| 6 |
| 7 #include <vector> |
| 8 |
| 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" |
| 11 #include "base/debug/crash_logging.h" |
| 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" |
| 14 #include "base/sys_info.h" |
| 15 #include "components/crash/core/common/crash_keys.h" |
| 16 #include "components/upload_list/crash_upload_list.h" |
| 17 #include "components/version_info/version_info_values.h" |
| 18 #include "services/ui/gpu/gpu_service.h" |
| 19 |
| 20 #if !defined(OS_CHROMEOS) |
| 21 #error Unsupported platform |
| 22 #endif |
| 23 |
| 24 MashCrashReporterClient::MashCrashReporterClient() {} |
| 25 |
| 26 MashCrashReporterClient::~MashCrashReporterClient() {} |
| 27 |
| 28 void MashCrashReporterClient::GetProductNameAndVersion( |
| 29 const char** product_name, |
| 30 const char** version) { |
| 31 *product_name = "Chrome_ChromeOS"; |
| 32 *version = PRODUCT_VERSION; |
| 33 } |
| 34 |
| 35 base::FilePath MashCrashReporterClient::GetReporterLogFilename() { |
| 36 return base::FilePath(CrashUploadList::kReporterLogFilename); |
| 37 } |
| 38 |
| 39 bool MashCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) { |
| 40 // For development on Linux desktop just use /tmp. |
| 41 if (!base::SysInfo::IsRunningOnChromeOS()) { |
| 42 *crash_dir = base::FilePath("/tmp"); |
| 43 return true; |
| 44 } |
| 45 |
| 46 // TODO(jamescook): Refactor chrome::DIR_CRASH_DUMPS into //components/crash |
| 47 // and use it here. |
| 48 *crash_dir = base::FilePath("/var/log/chrome/Crash Reports"); |
| 49 DCHECK(base::PathExists(*crash_dir)); |
| 50 return true; |
| 51 } |
| 52 |
| 53 size_t MashCrashReporterClient::RegisterCrashKeys() { |
| 54 // Register keys used by non-browser processes launched by the service manager |
| 55 // (e.g. the GPU service). See chrome/common/crash_keys.cc. |
| 56 std::vector<base::debug::CrashKey> keys = { |
| 57 {ui::GpuService::kActiveUrlCrashKey, crash_keys::kLargeSize}, |
| 58 |
| 59 // TODO(jamescook): These strings are copy/pasted across the codebase. |
| 60 // Switch to constants instead. |
| 61 {"total-discardable-memory-allocated", crash_keys::kSmallSize}, |
| 62 {"discardable-memory-free", crash_keys::kSmallSize}, |
| 63 }; |
| 64 crash_keys::GetCrashKeysForCommandLineSwitches(&keys); |
| 65 return base::debug::InitCrashKeys(&keys.at(0), keys.size(), |
| 66 crash_keys::kChunkMaxLength); |
| 67 } |
| 68 |
| 69 bool MashCrashReporterClient::IsRunningUnattended() { |
| 70 return false; |
| 71 } |
| 72 |
| 73 bool MashCrashReporterClient::GetCollectStatsConsent() { |
| 74 #if defined(GOOGLE_CHROME_BUILD) |
| 75 // For development on Linux desktop allow crash reporting to be forced on. |
| 76 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 77 switches::kEnableCrashReporterForTesting)) { |
| 78 return true; |
| 79 } |
| 80 // TODO(jamescook): Refactor this to share code with |
| 81 // chrome/browser/google/google_update_settings_posix.cc. |
| 82 base::FilePath consent_file("/home/chronos/Consent To Send Stats"); |
| 83 return base::PathExists(consent_file); |
| 84 #else |
| 85 // Crash reporting is only supported in branded builds. |
| 86 return false; |
| 87 #endif // defined(GOOGLE_CHROME_BUILD) |
| 88 } |
| OLD | NEW |