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

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

Issue 1666363002: Delete old files after an update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self-review Created 4 years, 9 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 (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 #include <stddef.h> 11 #include <stddef.h>
12 #include <stdint.h> 12 #include <stdint.h>
13 13
14 #include <string> 14 #include <string>
15 15
16 #include "base/at_exit.h" 16 #include "base/at_exit.h"
17 #include "base/bind.h"
17 #include "base/command_line.h" 18 #include "base/command_line.h"
18 #include "base/file_version_info.h" 19 #include "base/file_version_info.h"
19 #include "base/files/file_path.h" 20 #include "base/files/file_path.h"
20 #include "base/files/file_util.h" 21 #include "base/files/file_util.h"
21 #include "base/files/scoped_temp_dir.h" 22 #include "base/files/scoped_temp_dir.h"
22 #include "base/macros.h" 23 #include "base/macros.h"
23 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
24 #include "base/path_service.h" 25 #include "base/path_service.h"
25 #include "base/process/launch.h" 26 #include "base/process/launch.h"
26 #include "base/process/memory.h" 27 #include "base/process/memory.h"
(...skipping 17 matching lines...) Expand all
44 #include "chrome/installer/setup/archive_patch_helper.h" 45 #include "chrome/installer/setup/archive_patch_helper.h"
45 #include "chrome/installer/setup/install.h" 46 #include "chrome/installer/setup/install.h"
46 #include "chrome/installer/setup/install_worker.h" 47 #include "chrome/installer/setup/install_worker.h"
47 #include "chrome/installer/setup/installer_crash_reporting.h" 48 #include "chrome/installer/setup/installer_crash_reporting.h"
48 #include "chrome/installer/setup/installer_metrics.h" 49 #include "chrome/installer/setup/installer_metrics.h"
49 #include "chrome/installer/setup/setup_constants.h" 50 #include "chrome/installer/setup/setup_constants.h"
50 #include "chrome/installer/setup/setup_util.h" 51 #include "chrome/installer/setup/setup_util.h"
51 #include "chrome/installer/setup/uninstall.h" 52 #include "chrome/installer/setup/uninstall.h"
52 #include "chrome/installer/util/browser_distribution.h" 53 #include "chrome/installer/util/browser_distribution.h"
53 #include "chrome/installer/util/delete_after_reboot_helper.h" 54 #include "chrome/installer/util/delete_after_reboot_helper.h"
55 #include "chrome/installer/util/delete_old_versions.h"
54 #include "chrome/installer/util/delete_tree_work_item.h" 56 #include "chrome/installer/util/delete_tree_work_item.h"
55 #include "chrome/installer/util/google_update_constants.h" 57 #include "chrome/installer/util/google_update_constants.h"
56 #include "chrome/installer/util/google_update_settings.h" 58 #include "chrome/installer/util/google_update_settings.h"
57 #include "chrome/installer/util/google_update_util.h" 59 #include "chrome/installer/util/google_update_util.h"
58 #include "chrome/installer/util/helper.h" 60 #include "chrome/installer/util/helper.h"
59 #include "chrome/installer/util/html_dialog.h" 61 #include "chrome/installer/util/html_dialog.h"
60 #include "chrome/installer/util/install_util.h" 62 #include "chrome/installer/util/install_util.h"
61 #include "chrome/installer/util/installation_state.h" 63 #include "chrome/installer/util/installation_state.h"
62 #include "chrome/installer/util/installation_validator.h" 64 #include "chrome/installer/util/installation_validator.h"
63 #include "chrome/installer/util/installer_state.h" 65 #include "chrome/installer/util/installer_state.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 << BrowserDistribution::GetSpecificDistribution(type)-> 318 << BrowserDistribution::GetSpecificDistribution(type)->
317 GetDisplayName(); 319 GetDisplayName();
318 } 320 }
319 } 321 }
320 } 322 }
321 } 323 }
322 } 324 }
323 325
324 // This function is called when --rename-chrome-exe option is specified on 326 // This function is called when --rename-chrome-exe option is specified on
325 // setup.exe command line. This function assumes an in-use update has happened 327 // setup.exe command line. This function assumes an in-use update has happened
326 // for Chrome so there should be a file called new_chrome.exe on the file 328 // for Chrome so there should be a file called new_chrome.exe on the file system
327 // system and a key called 'opv' in the registry. This function will move 329 // and a key called 'opv' in the registry. This function will move
328 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation. 330 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation.
329 // This function also deletes elevation policies associated with the old version 331 // This function also takes care of deleting files and elevation policies that
330 // if they exist. 332 // belong to old versions of Chrome.
331 installer::InstallStatus RenameChromeExecutables( 333 installer::InstallStatus RenameChromeExecutables(
332 const InstallationState& original_state, 334 const InstallationState& original_state,
333 InstallerState* installer_state) { 335 InstallerState* installer_state) {
334 // See what products are already installed in multi mode. When we do the 336 // See what products are already installed in multi mode. When we do the
335 // rename for multi installs, we must update all installations since they 337 // rename for multi installs, we must update all installations since they
336 // share the binaries. 338 // share the binaries.
337 AddExistingMultiInstalls(original_state, installer_state); 339 AddExistingMultiInstalls(original_state, installer_state);
338 const base::FilePath &target_path = installer_state->target_path(); 340 const base::FilePath &target_path = installer_state->target_path();
339 base::FilePath chrome_exe(target_path.Append(installer::kChromeExe)); 341 base::FilePath chrome_exe(target_path.Append(installer::kChromeExe));
340 base::FilePath chrome_new_exe(target_path.Append(installer::kChromeNewExe)); 342 base::FilePath chrome_new_exe(target_path.Append(installer::kChromeNewExe));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 install_list->AddDeleteRegValueWorkItem( 382 install_list->AddDeleteRegValueWorkItem(
381 reg_root, 383 reg_root,
382 version_key, 384 version_key,
383 KEY_WOW64_32KEY, 385 KEY_WOW64_32KEY,
384 google_update::kRegCriticalVersionField); 386 google_update::kRegCriticalVersionField);
385 install_list->AddDeleteRegValueWorkItem(reg_root, 387 install_list->AddDeleteRegValueWorkItem(reg_root,
386 version_key, 388 version_key,
387 KEY_WOW64_32KEY, 389 KEY_WOW64_32KEY,
388 google_update::kRegRenameCmdField); 390 google_update::kRegRenameCmdField);
389 } 391 }
392
393 // Delete old versions.
394 // TODO(fdoray): Launch a cleanup process when this fails. crbug.com/451546
395 AddDeleteOldVersionsWorkItem(*installer_state, install_list.get())
396 ->set_ignore_failure(true);
397
390 installer::InstallStatus ret = installer::RENAME_SUCCESSFUL; 398 installer::InstallStatus ret = installer::RENAME_SUCCESSFUL;
391 if (!install_list->Do()) { 399 if (!install_list->Do()) {
392 LOG(ERROR) << "Renaming of executables failed. Rolling back any changes."; 400 LOG(ERROR) << "Renaming of executables failed. Rolling back any changes.";
393 install_list->Rollback(); 401 install_list->Rollback();
394 ret = installer::RENAME_FAILED; 402 ret = installer::RENAME_FAILED;
395 } 403 }
396 // temp_path's dtor will take care of deleting or scheduling itself for 404 // temp_path's dtor will take care of deleting or scheduling itself for
397 // deletion at reboot when this scope closes. 405 // deletion at reboot when this scope closes.
398 VLOG(1) << "Deleting temporary directory " << temp_path.path().value(); 406 VLOG(1) << "Deleting temporary directory " << temp_path.path().value();
399 407
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 // to pass through, since this is only returned on uninstall which is 1793 // to pass through, since this is only returned on uninstall which is
1786 // never invoked directly by Google Update. 1794 // never invoked directly by Google Update.
1787 return_code = InstallUtil::GetInstallReturnCode(install_status); 1795 return_code = InstallUtil::GetInstallReturnCode(install_status);
1788 } 1796 }
1789 1797
1790 installer::EndPersistentHistogramStorage(installer_state.target_path()); 1798 installer::EndPersistentHistogramStorage(installer_state.target_path());
1791 VLOG(1) << "Installation complete, returning: " << return_code; 1799 VLOG(1) << "Installation complete, returning: " << return_code;
1792 1800
1793 return return_code; 1801 return return_code;
1794 } 1802 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698