Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: chrome/installer/setup/installer_crash_reporting.cc

Issue 2797433002: Include Google Update integration details in crash keys and about:version. (Closed)
Patch Set: components/version_ui/OWNERS now own version_ui_strings.grdp Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/crash_logging.h" 12 #include "base/debug/crash_logging.h"
13 #include "base/debug/leak_annotations.h" 13 #include "base/debug/leak_annotations.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/version.h" 18 #include "base/version.h"
19 #include "base/win/registry.h" 19 #include "base/win/registry.h"
20 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
21 #include "chrome/install_static/install_details.h"
21 #include "chrome/installer/setup/installer_crash_reporter_client.h" 22 #include "chrome/installer/setup/installer_crash_reporter_client.h"
22 #include "chrome/installer/setup/installer_state.h" 23 #include "chrome/installer/setup/installer_state.h"
23 #include "chrome/installer/util/google_update_settings.h" 24 #include "chrome/installer/util/google_update_settings.h"
24 #include "components/crash/content/app/crash_keys_win.h" 25 #include "components/crash/content/app/crash_keys_win.h"
25 #include "components/crash/content/app/crashpad.h" 26 #include "components/crash/content/app/crashpad.h"
26 #include "components/crash/core/common/crash_keys.h" 27 #include "components/crash/core/common/crash_keys.h"
27 28
28 namespace installer { 29 namespace installer {
29 30
30 namespace { 31 namespace {
31 32
32 // Crash Keys 33 // Crash Keys
33 34
35 const char kApValue[] = "ap";
36 const char kCohortName[] = "cohort-name";
34 const char kCurrentVersion[] = "current-version"; 37 const char kCurrentVersion[] = "current-version";
35 const char kIsSystemLevel[] = "system-level"; 38 const char kIsSystemLevel[] = "system-level";
36 const char kOperation[] = "operation"; 39 const char kOperation[] = "operation";
37 const char kStateKey[] = "state-key"; 40 const char kStateKey[] = "state-key";
38 41
39 const char *OperationToString(InstallerState::Operation operation) { 42 const char *OperationToString(InstallerState::Operation operation) {
40 switch (operation) { 43 switch (operation) {
41 case InstallerState::SINGLE_INSTALL_OR_UPDATE: 44 case InstallerState::SINGLE_INSTALL_OR_UPDATE:
42 return "single-install-or-update"; 45 return "single-install-or-update";
43 case InstallerState::UNINSTALL: 46 case InstallerState::UNINSTALL:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 "Chrome Installer"); 97 "Chrome Installer");
95 98
96 // Set up the metrics client id (a la child_process_logging::Init()). 99 // Set up the metrics client id (a la child_process_logging::Init()).
97 std::unique_ptr<metrics::ClientInfo> client_info = 100 std::unique_ptr<metrics::ClientInfo> client_info =
98 GoogleUpdateSettings::LoadMetricsClientInfo(); 101 GoogleUpdateSettings::LoadMetricsClientInfo();
99 if (client_info) 102 if (client_info)
100 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id); 103 crash_keys::SetMetricsClientIdFromGUID(client_info->client_id);
101 } 104 }
102 105
103 size_t RegisterCrashKeys() { 106 size_t RegisterCrashKeys() {
104 const base::debug::CrashKey kFixedKeys[] = { 107 static constexpr base::debug::CrashKey kFixedKeys[] = {
105 { crash_keys::kMetricsClientId, crash_keys::kSmallSize }, 108 {crash_keys::kMetricsClientId, crash_keys::kSmallSize},
106 { kCurrentVersion, crash_keys::kSmallSize }, 109 {kApValue, crash_keys::kSmallSize},
107 { kIsSystemLevel, crash_keys::kSmallSize }, 110 {kCohortName, crash_keys::kSmallSize},
108 { kOperation, crash_keys::kSmallSize }, 111 {kCurrentVersion, crash_keys::kSmallSize},
112 {kIsSystemLevel, crash_keys::kSmallSize},
113 {kOperation, crash_keys::kSmallSize},
109 114
110 // This is a Windows registry key, which maxes out at 255 chars. 115 // This is a Windows registry key, which maxes out at 255 chars.
111 // (kMediumSize actually maxes out at 252 chars on Windows, but potentially 116 // (kMediumSize actually maxes out at 252 chars on Windows, but
112 // truncating such a small amount is a fair tradeoff compared to using 117 // potentially truncating such a small amount is a fair tradeoff compared
113 // kLargeSize, which is wasteful.) 118 // to using kLargeSize, which is wasteful.)
114 { kStateKey, crash_keys::kMediumSize }, 119 {kStateKey, crash_keys::kMediumSize},
115 }; 120 };
116 std::vector<base::debug::CrashKey> keys(std::begin(kFixedKeys), 121 std::vector<base::debug::CrashKey> keys(std::begin(kFixedKeys),
117 std::end(kFixedKeys)); 122 std::end(kFixedKeys));
118 crash_keys::GetCrashKeysForCommandLineSwitches(&keys); 123 crash_keys::GetCrashKeysForCommandLineSwitches(&keys);
119 return base::debug::InitCrashKeys(keys.data(), keys.size(), 124 return base::debug::InitCrashKeys(keys.data(), keys.size(),
120 crash_keys::kChunkMaxLength); 125 crash_keys::kChunkMaxLength);
121 } 126 }
122 127
123 void SetInitialCrashKeys(const InstallerState& state) { 128 void SetInitialCrashKeys(const InstallerState& state) {
124 using base::debug::SetCrashKeyValue; 129 using base::debug::SetCrashKeyValue;
125 130
126 SetCrashKeyValue(kOperation, OperationToString(state.operation())); 131 SetCrashKeyValue(kOperation, OperationToString(state.operation()));
127 SetCrashKeyValue(kIsSystemLevel, state.system_install() ? "true" : "false"); 132 SetCrashKeyValue(kIsSystemLevel, state.system_install() ? "true" : "false");
128 133
129 const base::string16 state_key = state.state_key(); 134 const base::string16 state_key = state.state_key();
130 if (!state_key.empty()) 135 if (!state_key.empty())
131 SetCrashKeyValue(kStateKey, base::UTF16ToUTF8(state_key)); 136 SetCrashKeyValue(kStateKey, base::UTF16ToUTF8(state_key));
137
138 // Set crash keys containing the registry values used to determine Chrome's
139 // update channel at process startup; see https://crbug.com/579504.
140 const auto& details = install_static::InstallDetails::Get();
141 base::debug::SetCrashKeyValue(kApValue,
142 base::UTF16ToUTF8(details.update_ap()));
143 base::debug::SetCrashKeyValue(
144 kCohortName, base::UTF16ToUTF8(details.update_cohort_name()));
132 } 145 }
133 146
134 void SetCrashKeysFromCommandLine(const base::CommandLine& command_line) { 147 void SetCrashKeysFromCommandLine(const base::CommandLine& command_line) {
135 crash_keys::SetSwitchesFromCommandLine(command_line, nullptr); 148 crash_keys::SetSwitchesFromCommandLine(command_line, nullptr);
136 } 149 }
137 150
138 void SetCurrentVersionCrashKey(const base::Version* current_version) { 151 void SetCurrentVersionCrashKey(const base::Version* current_version) {
139 if (current_version) { 152 if (current_version) {
140 base::debug::SetCrashKeyValue(kCurrentVersion, 153 base::debug::SetCrashKeyValue(kCurrentVersion,
141 current_version->GetString()); 154 current_version->GetString());
142 } else { 155 } else {
143 base::debug::ClearCrashKey(kCurrentVersion); 156 base::debug::ClearCrashKey(kCurrentVersion);
144 } 157 }
145 } 158 }
146 159
147 } // namespace installer 160 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/install_static/product_install_details_unittest.cc ('k') | chrome/installer/setup/setup_install_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698