| 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 "chrome/installer/setup/installer_crash_reporting.h" | 5 #include "chrome/installer/setup/installer_crash_reporting.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 #include <memory> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/debug/crash_logging.h" | 12 #include "base/debug/crash_logging.h" |
| 12 #include "base/debug/leak_annotations.h" | 13 #include "base/debug/leak_annotations.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 15 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/version.h" | 18 #include "base/version.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 break; | 51 break; |
| 51 } | 52 } |
| 52 NOTREACHED(); | 53 NOTREACHED(); |
| 53 return ""; | 54 return ""; |
| 54 } | 55 } |
| 55 | 56 |
| 56 const char *OperationToString(InstallerState::Operation operation) { | 57 const char *OperationToString(InstallerState::Operation operation) { |
| 57 switch (operation) { | 58 switch (operation) { |
| 58 case InstallerState::SINGLE_INSTALL_OR_UPDATE: | 59 case InstallerState::SINGLE_INSTALL_OR_UPDATE: |
| 59 return "single-install-or-update"; | 60 return "single-install-or-update"; |
| 60 case InstallerState::MULTI_INSTALL: | |
| 61 return "multi-install"; | |
| 62 case InstallerState::MULTI_UPDATE: | |
| 63 return "multi-update"; | |
| 64 case InstallerState::UNINSTALL: | 61 case InstallerState::UNINSTALL: |
| 65 return "uninstall"; | 62 return "uninstall"; |
| 66 case InstallerState::UNINITIALIZED: | 63 case InstallerState::UNINITIALIZED: |
| 67 // Fall out of switch. | 64 // Fall out of switch. |
| 68 break; | 65 break; |
| 69 } | 66 } |
| 70 NOTREACHED(); | 67 NOTREACHED(); |
| 71 return ""; | 68 return ""; |
| 72 } | 69 } |
| 73 | 70 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 87 | 84 |
| 88 } // namespace | 85 } // namespace |
| 89 | 86 |
| 90 void ConfigureCrashReporting(const InstallerState& installer_state) { | 87 void ConfigureCrashReporting(const InstallerState& installer_state) { |
| 91 // This is inspired by work done in various parts of Chrome startup to connect | 88 // This is inspired by work done in various parts of Chrome startup to connect |
| 92 // to the crash service. Since the installer does not split its work between | 89 // to the crash service. Since the installer does not split its work between |
| 93 // a stub .exe and a main .dll, crash reporting can be configured in one place | 90 // a stub .exe and a main .dll, crash reporting can be configured in one place |
| 94 // right here. | 91 // right here. |
| 95 | 92 |
| 96 // Create the crash client and install it (a la MainDllLoader::Launch). | 93 // Create the crash client and install it (a la MainDllLoader::Launch). |
| 97 InstallerCrashReporterClient *crash_client = | 94 InstallerCrashReporterClient* crash_client = |
| 98 new InstallerCrashReporterClient(!installer_state.system_install()); | 95 new InstallerCrashReporterClient(!installer_state.system_install()); |
| 99 ANNOTATE_LEAKING_OBJECT_PTR(crash_client); | 96 ANNOTATE_LEAKING_OBJECT_PTR(crash_client); |
| 100 crash_reporter::SetCrashReporterClient(crash_client); | 97 crash_reporter::SetCrashReporterClient(crash_client); |
| 101 | 98 |
| 102 if (installer_state.system_install()) { | 99 if (installer_state.system_install()) { |
| 103 base::FilePath temp_dir; | 100 base::FilePath temp_dir; |
| 104 if (GetSystemTemp(&temp_dir)) { | 101 if (GetSystemTemp(&temp_dir)) { |
| 105 base::FilePath crash_dir = temp_dir.Append(FILE_PATH_LITERAL("Crashpad")); | 102 base::FilePath crash_dir = temp_dir.Append(FILE_PATH_LITERAL("Crashpad")); |
| 106 PathService::OverrideAndCreateIfNeeded(chrome::DIR_CRASH_DUMPS, crash_dir, | 103 PathService::OverrideAndCreateIfNeeded(chrome::DIR_CRASH_DUMPS, crash_dir, |
| 107 true, true); | 104 true, true); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return base::debug::InitCrashKeys(keys.data(), keys.size(), | 139 return base::debug::InitCrashKeys(keys.data(), keys.size(), |
| 143 crash_keys::kChunkMaxLength); | 140 crash_keys::kChunkMaxLength); |
| 144 } | 141 } |
| 145 | 142 |
| 146 void SetInitialCrashKeys(const InstallerState& state) { | 143 void SetInitialCrashKeys(const InstallerState& state) { |
| 147 using base::debug::SetCrashKeyValue; | 144 using base::debug::SetCrashKeyValue; |
| 148 | 145 |
| 149 SetCrashKeyValue(kDistributionType, | 146 SetCrashKeyValue(kDistributionType, |
| 150 DistributionTypeToString(state.state_type())); | 147 DistributionTypeToString(state.state_type())); |
| 151 SetCrashKeyValue(kOperation, OperationToString(state.operation())); | 148 SetCrashKeyValue(kOperation, OperationToString(state.operation())); |
| 152 SetCrashKeyValue(kIsMultiInstall, | 149 SetCrashKeyValue(kIsMultiInstall, "false"); |
| 153 state.is_multi_install() ? "true" : "false"); | |
| 154 SetCrashKeyValue(kIsSystemLevel, state.system_install() ? "true" : "false"); | 150 SetCrashKeyValue(kIsSystemLevel, state.system_install() ? "true" : "false"); |
| 155 | 151 |
| 156 const base::string16 state_key = state.state_key(); | 152 const base::string16 state_key = state.state_key(); |
| 157 if (!state_key.empty()) | 153 if (!state_key.empty()) |
| 158 SetCrashKeyValue(kStateKey, base::UTF16ToUTF8(state_key)); | 154 SetCrashKeyValue(kStateKey, base::UTF16ToUTF8(state_key)); |
| 159 } | 155 } |
| 160 | 156 |
| 161 void SetCrashKeysFromCommandLine(const base::CommandLine& command_line) { | 157 void SetCrashKeysFromCommandLine(const base::CommandLine& command_line) { |
| 162 crash_keys::SetSwitchesFromCommandLine(command_line, nullptr); | 158 crash_keys::SetSwitchesFromCommandLine(command_line, nullptr); |
| 163 } | 159 } |
| 164 | 160 |
| 165 void SetCurrentVersionCrashKey(const base::Version* current_version) { | 161 void SetCurrentVersionCrashKey(const base::Version* current_version) { |
| 166 if (current_version) { | 162 if (current_version) { |
| 167 base::debug::SetCrashKeyValue(kCurrentVersion, | 163 base::debug::SetCrashKeyValue(kCurrentVersion, |
| 168 current_version->GetString()); | 164 current_version->GetString()); |
| 169 } else { | 165 } else { |
| 170 base::debug::ClearCrashKey(kCurrentVersion); | 166 base::debug::ClearCrashKey(kCurrentVersion); |
| 171 } | 167 } |
| 172 } | 168 } |
| 173 | 169 |
| 174 } // namespace installer | 170 } // namespace installer |
| OLD | NEW |