| 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 |
| 19 #if !defined(OS_CHROMEOS) |
| 20 #error Unsupported platform |
| 21 #endif |
| 22 |
| 23 MashCrashReporterClient::MashCrashReporterClient() {} |
| 24 |
| 25 MashCrashReporterClient::~MashCrashReporterClient() {} |
| 26 |
| 27 void MashCrashReporterClient::GetProductNameAndVersion( |
| 28 const char** product_name, |
| 29 const char** version) { |
| 30 *product_name = "Chrome_ChromeOS"; |
| 31 *version = PRODUCT_VERSION; |
| 32 } |
| 33 |
| 34 base::FilePath MashCrashReporterClient::GetReporterLogFilename() { |
| 35 return base::FilePath(CrashUploadList::kReporterLogFilename); |
| 36 } |
| 37 |
| 38 bool MashCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) { |
| 39 // For development on Linux desktop just use /tmp. |
| 40 if (!base::SysInfo::IsRunningOnChromeOS()) { |
| 41 *crash_dir = base::FilePath("/tmp"); |
| 42 return true; |
| 43 } |
| 44 |
| 45 // TODO(jamescook): Refactor chrome::DIR_CRASH_DUMPS into //components/crash |
| 46 // and use it here. |
| 47 *crash_dir = base::FilePath("/var/log/chrome/Crash Reports"); |
| 48 DCHECK(base::PathExists(*crash_dir)); |
| 49 return true; |
| 50 } |
| 51 |
| 52 size_t MashCrashReporterClient::RegisterCrashKeys() { |
| 53 // Register keys used by non-browser processes launched by the service manager |
| 54 // (e.g. the GPU service). See chrome/common/crash_keys.cc. |
| 55 std::vector<base::debug::CrashKey> keys = { |
| 56 {"url-chunk", crash_keys::kLargeSize}, |
| 57 {"total-discardable-memory-allocated", crash_keys::kSmallSize}, |
| 58 {"discardable-memory-free", crash_keys::kSmallSize}, |
| 59 }; |
| 60 crash_keys::GetCrashKeysForCommandLineSwitches(&keys); |
| 61 return base::debug::InitCrashKeys(&keys.at(0), keys.size(), |
| 62 crash_keys::kChunkMaxLength); |
| 63 } |
| 64 |
| 65 bool MashCrashReporterClient::IsRunningUnattended() { |
| 66 return false; |
| 67 } |
| 68 |
| 69 bool MashCrashReporterClient::GetCollectStatsConsent() { |
| 70 #if defined(GOOGLE_CHROME_BUILD) |
| 71 // For development on Linux desktop allow crash reporting to be forced on. |
| 72 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 73 switches::kEnableCrashReporterForTesting)) { |
| 74 return true; |
| 75 } |
| 76 // TODO(jamescook): Refactor this to share code with |
| 77 // chrome/browser/google/google_update_settings_posix.cc. |
| 78 base::FilePath consent_file("/home/chronos/Consent To Send Stats"); |
| 79 return base::PathExists(consent_file); |
| 80 #else |
| 81 // Crash reporting is only supported in branded builds. |
| 82 return false; |
| 83 #endif // defined(GOOGLE_CHROME_BUILD) |
| 84 } |
| OLD | NEW |