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

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, 10 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 16 matching lines...) Expand all
43 #include "chrome/common/chrome_switches.h" 44 #include "chrome/common/chrome_switches.h"
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/setup_constants.h" 49 #include "chrome/installer/setup/setup_constants.h"
49 #include "chrome/installer/setup/setup_util.h" 50 #include "chrome/installer/setup/setup_util.h"
50 #include "chrome/installer/setup/uninstall.h" 51 #include "chrome/installer/setup/uninstall.h"
51 #include "chrome/installer/util/browser_distribution.h" 52 #include "chrome/installer/util/browser_distribution.h"
52 #include "chrome/installer/util/delete_after_reboot_helper.h" 53 #include "chrome/installer/util/delete_after_reboot_helper.h"
54 #include "chrome/installer/util/delete_old_versions.h"
53 #include "chrome/installer/util/delete_tree_work_item.h" 55 #include "chrome/installer/util/delete_tree_work_item.h"
54 #include "chrome/installer/util/google_update_constants.h" 56 #include "chrome/installer/util/google_update_constants.h"
55 #include "chrome/installer/util/google_update_settings.h" 57 #include "chrome/installer/util/google_update_settings.h"
56 #include "chrome/installer/util/google_update_util.h" 58 #include "chrome/installer/util/google_update_util.h"
57 #include "chrome/installer/util/helper.h" 59 #include "chrome/installer/util/helper.h"
58 #include "chrome/installer/util/html_dialog.h" 60 #include "chrome/installer/util/html_dialog.h"
59 #include "chrome/installer/util/install_util.h" 61 #include "chrome/installer/util/install_util.h"
60 #include "chrome/installer/util/installation_state.h" 62 #include "chrome/installer/util/installation_state.h"
61 #include "chrome/installer/util/installation_validator.h" 63 #include "chrome/installer/util/installation_validator.h"
62 #include "chrome/installer/util/installer_state.h" 64 #include "chrome/installer/util/installer_state.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 << BrowserDistribution::GetSpecificDistribution(type)-> 313 << BrowserDistribution::GetSpecificDistribution(type)->
312 GetDisplayName(); 314 GetDisplayName();
313 } 315 }
314 } 316 }
315 } 317 }
316 } 318 }
317 } 319 }
318 320
319 // This function is called when --rename-chrome-exe option is specified on 321 // This function is called when --rename-chrome-exe option is specified on
320 // setup.exe command line. This function assumes an in-use update has happened 322 // setup.exe command line. This function assumes an in-use update has happened
321 // for Chrome so there should be a file called new_chrome.exe on the file 323 // for Chrome so there should be a file called new_chrome.exe on the file system
322 // system and a key called 'opv' in the registry. This function will move 324 // and a key called 'opv' in the registry. This function will move
323 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation. 325 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation.
324 // This function also deletes elevation policies associated with the old version 326 // This function also takes care of deleting files and elevation policies that
325 // if they exist. 327 // belong to old versions of Chrome.
326 installer::InstallStatus RenameChromeExecutables( 328 installer::InstallStatus RenameChromeExecutables(
327 const InstallationState& original_state, 329 const InstallationState& original_state,
328 InstallerState* installer_state) { 330 InstallerState* installer_state) {
329 // See what products are already installed in multi mode. When we do the 331 // See what products are already installed in multi mode. When we do the
330 // rename for multi installs, we must update all installations since they 332 // rename for multi installs, we must update all installations since they
331 // share the binaries. 333 // share the binaries.
332 AddExistingMultiInstalls(original_state, installer_state); 334 AddExistingMultiInstalls(original_state, installer_state);
333 const base::FilePath &target_path = installer_state->target_path(); 335 const base::FilePath &target_path = installer_state->target_path();
334 base::FilePath chrome_exe(target_path.Append(installer::kChromeExe)); 336 base::FilePath chrome_exe(target_path.Append(installer::kChromeExe));
335 base::FilePath chrome_new_exe(target_path.Append(installer::kChromeNewExe)); 337 base::FilePath chrome_new_exe(target_path.Append(installer::kChromeNewExe));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 install_list->AddDeleteRegValueWorkItem( 377 install_list->AddDeleteRegValueWorkItem(
376 reg_root, 378 reg_root,
377 version_key, 379 version_key,
378 KEY_WOW64_32KEY, 380 KEY_WOW64_32KEY,
379 google_update::kRegCriticalVersionField); 381 google_update::kRegCriticalVersionField);
380 install_list->AddDeleteRegValueWorkItem(reg_root, 382 install_list->AddDeleteRegValueWorkItem(reg_root,
381 version_key, 383 version_key,
382 KEY_WOW64_32KEY, 384 KEY_WOW64_32KEY,
383 google_update::kRegRenameCmdField); 385 google_update::kRegRenameCmdField);
384 } 386 }
387
388 // Delete old versions.
389 // TODO(fdoray): Launch a cleanup process when this fails. crbug.com/451546
390 install_list
391 ->AddCallbackWorkItem(base::Bind(&DeleteOldVersionsCallback,
392 installer_state->target_path()))
393 ->set_ignore_failure(true);
394
385 installer::InstallStatus ret = installer::RENAME_SUCCESSFUL; 395 installer::InstallStatus ret = installer::RENAME_SUCCESSFUL;
386 if (!install_list->Do()) { 396 if (!install_list->Do()) {
387 LOG(ERROR) << "Renaming of executables failed. Rolling back any changes."; 397 LOG(ERROR) << "Renaming of executables failed. Rolling back any changes.";
388 install_list->Rollback(); 398 install_list->Rollback();
389 ret = installer::RENAME_FAILED; 399 ret = installer::RENAME_FAILED;
390 } 400 }
391 // temp_path's dtor will take care of deleting or scheduling itself for 401 // temp_path's dtor will take care of deleting or scheduling itself for
392 // deletion at reboot when this scope closes. 402 // deletion at reboot when this scope closes.
393 VLOG(1) << "Deleting temporary directory " << temp_path.path().value(); 403 VLOG(1) << "Deleting temporary directory " << temp_path.path().value();
394 404
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT 1777 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT
1768 // to pass through, since this is only returned on uninstall which is 1778 // to pass through, since this is only returned on uninstall which is
1769 // never invoked directly by Google Update. 1779 // never invoked directly by Google Update.
1770 return_code = InstallUtil::GetInstallReturnCode(install_status); 1780 return_code = InstallUtil::GetInstallReturnCode(install_status);
1771 } 1781 }
1772 1782
1773 VLOG(1) << "Installation complete, returning: " << return_code; 1783 VLOG(1) << "Installation complete, returning: " << return_code;
1774 1784
1775 return return_code; 1785 return return_code;
1776 } 1786 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698