| 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 <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "components/crash/content/app/crashpad.h" | 25 #include "components/crash/content/app/crashpad.h" |
| 26 #include "components/crash/core/common/crash_keys.h" | 26 #include "components/crash/core/common/crash_keys.h" |
| 27 | 27 |
| 28 namespace installer { | 28 namespace installer { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 // Crash Keys | 32 // Crash Keys |
| 33 | 33 |
| 34 const char kCurrentVersion[] = "current-version"; | 34 const char kCurrentVersion[] = "current-version"; |
| 35 const char kIsMultiInstall[] = "multi-install"; | |
| 36 const char kIsSystemLevel[] = "system-level"; | 35 const char kIsSystemLevel[] = "system-level"; |
| 37 const char kOperation[] = "operation"; | 36 const char kOperation[] = "operation"; |
| 38 const char kStateKey[] = "state-key"; | 37 const char kStateKey[] = "state-key"; |
| 39 | 38 |
| 40 const char *OperationToString(InstallerState::Operation operation) { | 39 const char *OperationToString(InstallerState::Operation operation) { |
| 41 switch (operation) { | 40 switch (operation) { |
| 42 case InstallerState::SINGLE_INSTALL_OR_UPDATE: | 41 case InstallerState::SINGLE_INSTALL_OR_UPDATE: |
| 43 return "single-install-or-update"; | 42 return "single-install-or-update"; |
| 44 case InstallerState::UNINSTALL: | 43 case InstallerState::UNINSTALL: |
| 45 return "uninstall"; | 44 return "uninstall"; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 std::unique_ptr<metrics::ClientInfo> client_info = | 97 std::unique_ptr<metrics::ClientInfo> client_info = |
| 99 GoogleUpdateSettings::LoadMetricsClientInfo(); | 98 GoogleUpdateSettings::LoadMetricsClientInfo(); |
| 100 if (client_info) | 99 if (client_info) |
| 101 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id); | 100 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id); |
| 102 } | 101 } |
| 103 | 102 |
| 104 size_t RegisterCrashKeys() { | 103 size_t RegisterCrashKeys() { |
| 105 const base::debug::CrashKey kFixedKeys[] = { | 104 const base::debug::CrashKey kFixedKeys[] = { |
| 106 { crash_keys::kMetricsClientId, crash_keys::kSmallSize }, | 105 { crash_keys::kMetricsClientId, crash_keys::kSmallSize }, |
| 107 { kCurrentVersion, crash_keys::kSmallSize }, | 106 { kCurrentVersion, crash_keys::kSmallSize }, |
| 108 { kIsMultiInstall, crash_keys::kSmallSize }, | |
| 109 { kIsSystemLevel, crash_keys::kSmallSize }, | 107 { kIsSystemLevel, crash_keys::kSmallSize }, |
| 110 { kOperation, crash_keys::kSmallSize }, | 108 { kOperation, crash_keys::kSmallSize }, |
| 111 | 109 |
| 112 // This is a Windows registry key, which maxes out at 255 chars. | 110 // This is a Windows registry key, which maxes out at 255 chars. |
| 113 // (kMediumSize actually maxes out at 252 chars on Windows, but potentially | 111 // (kMediumSize actually maxes out at 252 chars on Windows, but potentially |
| 114 // truncating such a small amount is a fair tradeoff compared to using | 112 // truncating such a small amount is a fair tradeoff compared to using |
| 115 // kLargeSize, which is wasteful.) | 113 // kLargeSize, which is wasteful.) |
| 116 { kStateKey, crash_keys::kMediumSize }, | 114 { kStateKey, crash_keys::kMediumSize }, |
| 117 }; | 115 }; |
| 118 std::vector<base::debug::CrashKey> keys(std::begin(kFixedKeys), | 116 std::vector<base::debug::CrashKey> keys(std::begin(kFixedKeys), |
| 119 std::end(kFixedKeys)); | 117 std::end(kFixedKeys)); |
| 120 crash_keys::GetCrashKeysForCommandLineSwitches(&keys); | 118 crash_keys::GetCrashKeysForCommandLineSwitches(&keys); |
| 121 return base::debug::InitCrashKeys(keys.data(), keys.size(), | 119 return base::debug::InitCrashKeys(keys.data(), keys.size(), |
| 122 crash_keys::kChunkMaxLength); | 120 crash_keys::kChunkMaxLength); |
| 123 } | 121 } |
| 124 | 122 |
| 125 void SetInitialCrashKeys(const InstallerState& state) { | 123 void SetInitialCrashKeys(const InstallerState& state) { |
| 126 using base::debug::SetCrashKeyValue; | 124 using base::debug::SetCrashKeyValue; |
| 127 | 125 |
| 128 SetCrashKeyValue(kOperation, OperationToString(state.operation())); | 126 SetCrashKeyValue(kOperation, OperationToString(state.operation())); |
| 129 SetCrashKeyValue(kIsMultiInstall, "false"); | |
| 130 SetCrashKeyValue(kIsSystemLevel, state.system_install() ? "true" : "false"); | 127 SetCrashKeyValue(kIsSystemLevel, state.system_install() ? "true" : "false"); |
| 131 | 128 |
| 132 const base::string16 state_key = state.state_key(); | 129 const base::string16 state_key = state.state_key(); |
| 133 if (!state_key.empty()) | 130 if (!state_key.empty()) |
| 134 SetCrashKeyValue(kStateKey, base::UTF16ToUTF8(state_key)); | 131 SetCrashKeyValue(kStateKey, base::UTF16ToUTF8(state_key)); |
| 135 } | 132 } |
| 136 | 133 |
| 137 void SetCrashKeysFromCommandLine(const base::CommandLine& command_line) { | 134 void SetCrashKeysFromCommandLine(const base::CommandLine& command_line) { |
| 138 crash_keys::SetSwitchesFromCommandLine(command_line, nullptr); | 135 crash_keys::SetSwitchesFromCommandLine(command_line, nullptr); |
| 139 } | 136 } |
| 140 | 137 |
| 141 void SetCurrentVersionCrashKey(const base::Version* current_version) { | 138 void SetCurrentVersionCrashKey(const base::Version* current_version) { |
| 142 if (current_version) { | 139 if (current_version) { |
| 143 base::debug::SetCrashKeyValue(kCurrentVersion, | 140 base::debug::SetCrashKeyValue(kCurrentVersion, |
| 144 current_version->GetString()); | 141 current_version->GetString()); |
| 145 } else { | 142 } else { |
| 146 base::debug::ClearCrashKey(kCurrentVersion); | 143 base::debug::ClearCrashKey(kCurrentVersion); |
| 147 } | 144 } |
| 148 } | 145 } |
| 149 | 146 |
| 150 } // namespace installer | 147 } // namespace installer |
| OLD | NEW |