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

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

Issue 1475643004: Add crash keys for the installer covering simple InstallerState fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move include file to fix last nit Created 5 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/setup_main.h" 5 #include "chrome/installer/setup/setup_main.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <msi.h> 8 #include <msi.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
11 11
12 #include <string> 12 #include <string>
13 13
14 #include "base/at_exit.h" 14 #include "base/at_exit.h"
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/debug/crash_logging.h"
18 #include "base/debug/leak_annotations.h"
19 #include "base/file_version_info.h" 17 #include "base/file_version_info.h"
20 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
21 #include "base/files/file_util.h" 19 #include "base/files/file_util.h"
22 #include "base/files/scoped_temp_dir.h" 20 #include "base/files/scoped_temp_dir.h"
23 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
24 #include "base/path_service.h" 22 #include "base/path_service.h"
25 #include "base/process/launch.h" 23 #include "base/process/launch.h"
26 #include "base/process/memory.h" 24 #include "base/process/memory.h"
27 #include "base/strings/string16.h" 25 #include "base/strings/string16.h"
28 #include "base/strings/string_number_conversions.h" 26 #include "base/strings/string_number_conversions.h"
29 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
30 #include "base/strings/stringprintf.h" 28 #include "base/strings/stringprintf.h"
31 #include "base/strings/utf_string_conversions.h" 29 #include "base/strings/utf_string_conversions.h"
32 #include "base/values.h" 30 #include "base/values.h"
33 #include "base/version.h" 31 #include "base/version.h"
34 #include "base/win/process_startup_helper.h" 32 #include "base/win/process_startup_helper.h"
35 #include "base/win/registry.h" 33 #include "base/win/registry.h"
36 #include "base/win/scoped_com_initializer.h" 34 #include "base/win/scoped_com_initializer.h"
37 #include "base/win/scoped_comptr.h" 35 #include "base/win/scoped_comptr.h"
38 #include "base/win/scoped_handle.h" 36 #include "base/win/scoped_handle.h"
39 #include "base/win/win_util.h" 37 #include "base/win/win_util.h"
40 #include "base/win/windows_version.h" 38 #include "base/win/windows_version.h"
41 #include "chrome/common/chrome_constants.h" 39 #include "chrome/common/chrome_constants.h"
42 #include "chrome/common/chrome_paths.h" 40 #include "chrome/common/chrome_paths.h"
43 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
44 #include "chrome/installer/setup/archive_patch_helper.h" 42 #include "chrome/installer/setup/archive_patch_helper.h"
45 #include "chrome/installer/setup/install.h" 43 #include "chrome/installer/setup/install.h"
46 #include "chrome/installer/setup/install_worker.h" 44 #include "chrome/installer/setup/install_worker.h"
47 #include "chrome/installer/setup/installer_crash_reporter_client.h" 45 #include "chrome/installer/setup/installer_crash_reporting.h"
48 #include "chrome/installer/setup/setup_constants.h" 46 #include "chrome/installer/setup/setup_constants.h"
49 #include "chrome/installer/setup/setup_util.h" 47 #include "chrome/installer/setup/setup_util.h"
50 #include "chrome/installer/setup/uninstall.h" 48 #include "chrome/installer/setup/uninstall.h"
51 #include "chrome/installer/util/browser_distribution.h" 49 #include "chrome/installer/util/browser_distribution.h"
52 #include "chrome/installer/util/delete_after_reboot_helper.h" 50 #include "chrome/installer/util/delete_after_reboot_helper.h"
53 #include "chrome/installer/util/delete_tree_work_item.h" 51 #include "chrome/installer/util/delete_tree_work_item.h"
54 #include "chrome/installer/util/google_update_constants.h" 52 #include "chrome/installer/util/google_update_constants.h"
55 #include "chrome/installer/util/google_update_settings.h" 53 #include "chrome/installer/util/google_update_settings.h"
56 #include "chrome/installer/util/google_update_util.h" 54 #include "chrome/installer/util/google_update_util.h"
57 #include "chrome/installer/util/helper.h" 55 #include "chrome/installer/util/helper.h"
58 #include "chrome/installer/util/html_dialog.h" 56 #include "chrome/installer/util/html_dialog.h"
59 #include "chrome/installer/util/install_util.h" 57 #include "chrome/installer/util/install_util.h"
60 #include "chrome/installer/util/installation_state.h" 58 #include "chrome/installer/util/installation_state.h"
61 #include "chrome/installer/util/installation_validator.h" 59 #include "chrome/installer/util/installation_validator.h"
62 #include "chrome/installer/util/installer_state.h" 60 #include "chrome/installer/util/installer_state.h"
63 #include "chrome/installer/util/installer_util_strings.h" 61 #include "chrome/installer/util/installer_util_strings.h"
64 #include "chrome/installer/util/l10n_string_util.h" 62 #include "chrome/installer/util/l10n_string_util.h"
65 #include "chrome/installer/util/logging_installer.h" 63 #include "chrome/installer/util/logging_installer.h"
66 #include "chrome/installer/util/lzma_util.h" 64 #include "chrome/installer/util/lzma_util.h"
67 #include "chrome/installer/util/master_preferences.h" 65 #include "chrome/installer/util/master_preferences.h"
68 #include "chrome/installer/util/master_preferences_constants.h" 66 #include "chrome/installer/util/master_preferences_constants.h"
69 #include "chrome/installer/util/self_cleaning_temp_dir.h" 67 #include "chrome/installer/util/self_cleaning_temp_dir.h"
70 #include "chrome/installer/util/shell_util.h" 68 #include "chrome/installer/util/shell_util.h"
71 #include "chrome/installer/util/user_experiment.h" 69 #include "chrome/installer/util/user_experiment.h"
72 #include "components/crash/content/app/breakpad_win.h"
73 #include "components/crash/content/app/crash_keys_win.h"
74 70
75 #if defined(GOOGLE_CHROME_BUILD) 71 #if defined(GOOGLE_CHROME_BUILD)
76 #include "chrome/installer/util/updating_app_registration_data.h" 72 #include "chrome/installer/util/updating_app_registration_data.h"
77 #endif 73 #endif
78 74
79 using installer::InstallerState; 75 using installer::InstallerState;
80 using installer::InstallationState; 76 using installer::InstallationState;
81 using installer::InstallationValidator; 77 using installer::InstallationValidator;
82 using installer::MasterPreferences; 78 using installer::MasterPreferences;
83 using installer::Product; 79 using installer::Product;
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 cmd_line.GetSwitchValueNative( 1274 cmd_line.GetSwitchValueNative(
1279 installer::switches::kSetDisplayVersionValue)); 1275 installer::switches::kSetDisplayVersionValue));
1280 *exit_code = OverwriteDisplayVersions(registry_product, registry_value); 1276 *exit_code = OverwriteDisplayVersions(registry_product, registry_value);
1281 } else { 1277 } else {
1282 handled = false; 1278 handled = false;
1283 } 1279 }
1284 1280
1285 return handled; 1281 return handled;
1286 } 1282 }
1287 1283
1288 #if defined(COMPONENT_BUILD)
1289 // Installed via base::debug::SetCrashKeyReportingFunctions.
1290 void SetCrashKeyValue(const base::StringPiece& key,
1291 const base::StringPiece& value) {
1292 DCHECK(breakpad::CrashKeysWin::keeper());
1293 breakpad::CrashKeysWin::keeper()->SetCrashKeyValue(base::UTF8ToUTF16(key),
1294 base::UTF8ToUTF16(value));
1295 }
1296
1297 // Installed via base::debug::SetCrashKeyReportingFunctions.
1298 void ClearCrashKey(const base::StringPiece& key) {
1299 DCHECK(breakpad::CrashKeysWin::keeper());
1300 breakpad::CrashKeysWin::keeper()->ClearCrashKeyValue(base::UTF8ToUTF16(key));
1301 }
1302 #endif // COMPONENT_BUILD
1303
1304 void ConfigureCrashReporting(const InstallerState& installer_state) {
1305 // This is inspired by work done in various parts of Chrome startup to connect
1306 // to the crash service. Since the installer does not split its work between
1307 // a stub .exe and a main .dll, crash reporting can be configured in one place
1308 // right here.
1309
1310 // Create the crash client and install it (a la MainDllLoader::Launch).
1311 InstallerCrashReporterClient *crash_client =
1312 new InstallerCrashReporterClient(!installer_state.system_install());
1313 ANNOTATE_LEAKING_OBJECT_PTR(crash_client);
1314 crash_reporter::SetCrashReporterClient(crash_client);
1315
1316 breakpad::InitCrashReporter("Chrome Installer");
1317
1318 // Set up crash keys and the client id (a la child_process_logging::Init()).
1319 #if defined(COMPONENT_BUILD)
1320 // breakpad::InitCrashReporter takes care of this for static builds but not
1321 // component builds due to intricacies of chrome.exe and chrome.dll sharing a
1322 // copy of base.dll in that case (for details, see the comment in
1323 // components/crash/content/app/breakpad_win.cc).
1324 crash_client->RegisterCrashKeys();
1325 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValue, &ClearCrashKey);
1326 #endif // COMPONENT_BUILD
1327
1328 scoped_ptr<metrics::ClientInfo> client_info =
1329 GoogleUpdateSettings::LoadMetricsClientInfo();
1330 if (client_info)
1331 crash_client->SetCrashReporterClientIdFromGUID(client_info->client_id);
1332 // TODO(grt): A lack of a client_id at this point generally means that Chrome
1333 // has yet to have been launched and picked one. Consider creating it and
1334 // setting it here for Chrome to use.
1335 }
1336
1337 // Uninstalls multi-install Chrome Frame if the current operation is a 1284 // Uninstalls multi-install Chrome Frame if the current operation is a
1338 // multi-install install or update. The operation is performed directly rather 1285 // multi-install install or update. The operation is performed directly rather
1339 // than delegated to the existing install since there is no facility in older 1286 // than delegated to the existing install since there is no facility in older
1340 // versions of setup.exe to uninstall GCF without touching the binaries. The 1287 // versions of setup.exe to uninstall GCF without touching the binaries. The
1341 // binaries will be uninstalled during later processing if they are not in-use 1288 // binaries will be uninstalled during later processing if they are not in-use
1342 // (see UninstallBinariesIfUnused). |original_state| and |installer_state| are 1289 // (see UninstallBinariesIfUnused). |original_state| and |installer_state| are
1343 // updated to reflect the state of the world following the operation. 1290 // updated to reflect the state of the world following the operation.
1344 void UninstallMultiChromeFrameIfPresent(const base::CommandLine& cmd_line, 1291 void UninstallMultiChromeFrameIfPresent(const base::CommandLine& cmd_line,
1345 const MasterPreferences& prefs, 1292 const MasterPreferences& prefs,
1346 InstallationState* original_state, 1293 InstallationState* original_state,
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 bool system_install = false; 1644 bool system_install = false;
1698 prefs.GetBool(installer::master_preferences::kSystemLevel, &system_install); 1645 prefs.GetBool(installer::master_preferences::kSystemLevel, &system_install);
1699 VLOG(1) << "system install is " << system_install; 1646 VLOG(1) << "system install is " << system_install;
1700 1647
1701 InstallationState original_state; 1648 InstallationState original_state;
1702 original_state.Initialize(); 1649 original_state.Initialize();
1703 1650
1704 InstallerState installer_state; 1651 InstallerState installer_state;
1705 installer_state.Initialize(cmd_line, prefs, original_state); 1652 installer_state.Initialize(cmd_line, prefs, original_state);
1706 1653
1707 ConfigureCrashReporting(installer_state); 1654 installer::ConfigureCrashReporting(installer_state);
1655 installer::SetInitialCrashKeys(installer_state);
1708 1656
1709 // Make sure the process exits cleanly on unexpected errors. 1657 // Make sure the process exits cleanly on unexpected errors.
1710 base::EnableTerminationOnHeapCorruption(); 1658 base::EnableTerminationOnHeapCorruption();
1711 base::EnableTerminationOnOutOfMemory(); 1659 base::EnableTerminationOnOutOfMemory();
1712 base::win::RegisterInvalidParamHandler(); 1660 base::win::RegisterInvalidParamHandler();
1713 base::win::SetupCRT(cmd_line); 1661 base::win::SetupCRT(cmd_line);
1714 1662
1715 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall); 1663 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall);
1716 1664
1717 // Check to make sure current system is WinXP or later. If not, log 1665 // Check to make sure current system is WinXP or later. If not, log
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT 1772 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT
1825 // to pass through, since this is only returned on uninstall which is 1773 // to pass through, since this is only returned on uninstall which is
1826 // never invoked directly by Google Update. 1774 // never invoked directly by Google Update.
1827 return_code = InstallUtil::GetInstallReturnCode(install_status); 1775 return_code = InstallUtil::GetInstallReturnCode(install_status);
1828 } 1776 }
1829 1777
1830 VLOG(1) << "Installation complete, returning: " << return_code; 1778 VLOG(1) << "Installation complete, returning: " << return_code;
1831 1779
1832 return return_code; 1780 return return_code;
1833 } 1781 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/installer_crash_reporting.cc ('k') | chrome/installer/util/installer_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698