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

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

Issue 1882923003: Add best-effort/allow rollback flags on WorkItem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simple_list_tests
Patch Set: Created 4 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 (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 // This file contains the definitions of the installer functions that build 5 // This file contains the definitions of the installer functions that build
6 // the WorkItemList used to install the application. 6 // the WorkItemList used to install the application.
7 7
8 #include "chrome/installer/setup/install_worker.h" 8 #include "chrome/installer/setup/install_worker.h"
9 9
10 #include <oaidl.h> 10 #include <oaidl.h>
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 const Product& product, 265 const Product& product,
266 WorkItemList* work_item_list) { 266 WorkItemList* work_item_list) {
267 DCHECK(installer_state.is_msi()) 267 DCHECK(installer_state.is_msi())
268 << "This must only be called for MSI installations!"; 268 << "This must only be called for MSI installations!";
269 269
270 HKEY reg_root = installer_state.root_key(); 270 HKEY reg_root = installer_state.root_key();
271 base::string16 uninstall_reg(product.distribution()->GetUninstallRegPath()); 271 base::string16 uninstall_reg(product.distribution()->GetUninstallRegPath());
272 272
273 WorkItem* delete_reg_key = work_item_list->AddDeleteRegKeyWorkItem( 273 WorkItem* delete_reg_key = work_item_list->AddDeleteRegKeyWorkItem(
274 reg_root, uninstall_reg, KEY_WOW64_32KEY); 274 reg_root, uninstall_reg, KEY_WOW64_32KEY);
275 delete_reg_key->set_ignore_failure(true); 275 delete_reg_key->set_best_effort(true);
276 } 276 }
277 277
278 // Adds Chrome specific install work items to |install_list|. 278 // Adds Chrome specific install work items to |install_list|.
279 // |current_version| can be NULL to indicate no Chrome is currently installed. 279 // |current_version| can be NULL to indicate no Chrome is currently installed.
280 void AddChromeWorkItems(const InstallationState& original_state, 280 void AddChromeWorkItems(const InstallationState& original_state,
281 const InstallerState& installer_state, 281 const InstallerState& installer_state,
282 const base::FilePath& setup_path, 282 const base::FilePath& setup_path,
283 const base::FilePath& archive_path, 283 const base::FilePath& archive_path,
284 const base::FilePath& src_path, 284 const base::FilePath& src_path,
285 const base::FilePath& temp_path, 285 const base::FilePath& temp_path,
286 const Version* current_version, 286 const Version* current_version,
287 const Version& new_version, 287 const Version& new_version,
288 WorkItemList* install_list) { 288 WorkItemList* install_list) {
289 const base::FilePath& target_path = installer_state.target_path(); 289 const base::FilePath& target_path = installer_state.target_path();
290 290
291 if (current_version) { 291 if (current_version) {
292 // Delete the archive from an existing install to save some disk space. We 292 // Delete the archive from an existing install to save some disk space.
293 // make this an unconditional work item since there's no need to roll this
294 // back; if installation fails we'll be moved to the "-full" channel anyway.
295 base::FilePath old_installer_dir( 293 base::FilePath old_installer_dir(
296 installer_state.GetInstallerDirectory(*current_version)); 294 installer_state.GetInstallerDirectory(*current_version));
297 base::FilePath old_archive( 295 base::FilePath old_archive(
298 old_installer_dir.Append(installer::kChromeArchive)); 296 old_installer_dir.Append(installer::kChromeArchive));
299 // Don't delete the archive that we are actually installing from. 297 // Don't delete the archive that we are actually installing from.
300 if (archive_path != old_archive) { 298 if (archive_path != old_archive) {
301 install_list->AddDeleteTreeWorkItem(old_archive, temp_path)-> 299 auto* delete_old_archive_work_item =
302 set_ignore_failure(true); 300 install_list->AddDeleteTreeWorkItem(old_archive, temp_path);
301 // Don't cause failure of |install_list| if this WorkItem fails.
302 delete_old_archive_work_item->set_best_effort(true);
303 // No need to roll this back; if installation fails we'll be moved to the
304 // "-full" channel anyway.
fdoray 2016/04/14 14:24:34 I don't understand what this comment means.
grt (UTC plus 2) 2016/04/14 15:47:02 'No need to roll this back...' The uncompressed ar
305 delete_old_archive_work_item->set_allow_rollback(false);
303 } 306 }
304 } 307 }
305 308
306 // Delete any new_chrome.exe if present (we will end up creating a new one 309 // Delete any new_chrome.exe if present (we will end up creating a new one
307 // if required) and then copy chrome.exe 310 // if required) and then copy chrome.exe
308 base::FilePath new_chrome_exe(target_path.Append(installer::kChromeNewExe)); 311 base::FilePath new_chrome_exe(target_path.Append(installer::kChromeNewExe));
309 312
310 install_list->AddDeleteTreeWorkItem(new_chrome_exe, temp_path); 313 install_list->AddDeleteTreeWorkItem(new_chrome_exe, temp_path);
311 314
312 // TODO(grt): Remove this check in M35. 315 // TODO(grt): Remove this check in M35.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 bool check_for_duplicates = (current_version && 370 bool check_for_duplicates = (current_version &&
368 *current_version == new_version); 371 *current_version == new_version);
369 install_list->AddMoveTreeWorkItem( 372 install_list->AddMoveTreeWorkItem(
370 src_path.AppendASCII(new_version.GetString()).value(), 373 src_path.AppendASCII(new_version.GetString()).value(),
371 target_path.AppendASCII(new_version.GetString()).value(), 374 target_path.AppendASCII(new_version.GetString()).value(),
372 temp_path.value(), 375 temp_path.value(),
373 check_for_duplicates ? WorkItem::CHECK_DUPLICATES : 376 check_for_duplicates ? WorkItem::CHECK_DUPLICATES :
374 WorkItem::ALWAYS_MOVE); 377 WorkItem::ALWAYS_MOVE);
375 378
376 // Delete any old_chrome.exe if present (ignore failure if it's in use). 379 // Delete any old_chrome.exe if present (ignore failure if it's in use).
377 install_list->AddDeleteTreeWorkItem( 380 install_list
378 target_path.Append(installer::kChromeOldExe), temp_path)-> 381 ->AddDeleteTreeWorkItem(target_path.Append(installer::kChromeOldExe),
379 set_ignore_failure(true); 382 temp_path)
383 ->set_best_effort(true);
380 } 384 }
381 385
382 // Adds work items to remove COM registration for |product|'s deprecated 386 // Adds work items to remove COM registration for |product|'s deprecated
383 // DelegateExecute verb handler. 387 // DelegateExecute verb handler.
384 void AddCleanupDelegateExecuteWorkItems(const InstallerState& installer_state, 388 void AddCleanupDelegateExecuteWorkItems(const InstallerState& installer_state,
385 const Product& product, 389 const Product& product,
386 WorkItemList* list) { 390 WorkItemList* list) {
387 if (product.is_chrome()) { 391 if (product.is_chrome()) {
388 VLOG(1) << "Adding unregistration items for DelegateExecute verb handler."; 392 VLOG(1) << "Adding unregistration items for DelegateExecute verb handler.";
389 const base::string16 handler_class_uuid = 393 const base::string16 handler_class_uuid =
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 setup_path, 1142 setup_path,
1139 current_version, 1143 current_version,
1140 new_version, 1144 new_version,
1141 install_list); 1145 install_list);
1142 } 1146 }
1143 1147
1144 void AddRegisterComDllWorkItems(const base::FilePath& dll_folder, 1148 void AddRegisterComDllWorkItems(const base::FilePath& dll_folder,
1145 const std::vector<base::FilePath>& dll_list, 1149 const std::vector<base::FilePath>& dll_list,
1146 bool system_level, 1150 bool system_level,
1147 bool do_register, 1151 bool do_register,
1148 bool ignore_failures, 1152 bool best_effort,
1149 WorkItemList* work_item_list) { 1153 WorkItemList* work_item_list) {
1150 DCHECK(work_item_list); 1154 DCHECK(work_item_list);
1151 if (dll_list.empty()) { 1155 if (dll_list.empty()) {
1152 VLOG(1) << "No COM DLLs to register"; 1156 VLOG(1) << "No COM DLLs to register";
1153 } else { 1157 } else {
1154 std::vector<base::FilePath>::const_iterator dll_iter(dll_list.begin()); 1158 std::vector<base::FilePath>::const_iterator dll_iter(dll_list.begin());
1155 for (; dll_iter != dll_list.end(); ++dll_iter) { 1159 for (; dll_iter != dll_list.end(); ++dll_iter) {
1156 base::FilePath dll_path = dll_folder.Append(*dll_iter); 1160 base::FilePath dll_path = dll_folder.Append(*dll_iter);
1157 WorkItem* work_item = work_item_list->AddSelfRegWorkItem( 1161 WorkItem* work_item = work_item_list->AddSelfRegWorkItem(
1158 dll_path.value(), do_register, !system_level); 1162 dll_path.value(), do_register, !system_level);
1159 DCHECK(work_item); 1163 DCHECK(work_item);
1160 work_item->set_ignore_failure(ignore_failures); 1164 work_item->set_best_effort(best_effort);
1161 } 1165 }
1162 } 1166 }
1163 } 1167 }
1164 1168
1165 void AddSetMsiMarkerWorkItem(const InstallerState& installer_state, 1169 void AddSetMsiMarkerWorkItem(const InstallerState& installer_state,
1166 BrowserDistribution* dist, 1170 BrowserDistribution* dist,
1167 bool set, 1171 bool set,
1168 WorkItemList* work_item_list) { 1172 WorkItemList* work_item_list) {
1169 DCHECK(work_item_list); 1173 DCHECK(work_item_list);
1170 DWORD msi_value = set ? 1 : 0; 1174 DWORD msi_value = set ? 1 : 0;
1171 WorkItem* set_msi_work_item = 1175 WorkItem* set_msi_work_item =
1172 work_item_list->AddSetRegValueWorkItem(installer_state.root_key(), 1176 work_item_list->AddSetRegValueWorkItem(installer_state.root_key(),
1173 dist->GetStateKey(), 1177 dist->GetStateKey(),
1174 KEY_WOW64_32KEY, 1178 KEY_WOW64_32KEY,
1175 google_update::kRegMSIField, 1179 google_update::kRegMSIField,
1176 msi_value, 1180 msi_value,
1177 true); 1181 true);
1178 DCHECK(set_msi_work_item); 1182 DCHECK(set_msi_work_item);
1179 set_msi_work_item->set_ignore_failure(true); 1183 set_msi_work_item->set_best_effort(true);
1180 set_msi_work_item->set_log_message("Could not write MSI marker!"); 1184 set_msi_work_item->set_log_message("Could not write MSI marker!");
1181 } 1185 }
1182 1186
1183 void AddCleanupDeprecatedPerUserRegistrationsWorkItems(const Product& product, 1187 void AddCleanupDeprecatedPerUserRegistrationsWorkItems(const Product& product,
1184 WorkItemList* list) { 1188 WorkItemList* list) {
1185 if (product.is_chrome()) { 1189 if (product.is_chrome()) {
1186 BrowserDistribution* dist = product.distribution(); 1190 BrowserDistribution* dist = product.distribution();
1187 1191
1188 // TODO(gab): Remove cleanup code for Metro after M53. 1192 // TODO(gab): Remove cleanup code for Metro after M53.
1189 VLOG(1) << "Adding unregistration items for per-user Metro keys."; 1193 VLOG(1) << "Adding unregistration items for per-user Metro keys.";
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 // Unconditionally remove the legacy Quick Enable command from the binaries. 1358 // Unconditionally remove the legacy Quick Enable command from the binaries.
1355 // Do this even if multi-install Chrome isn't installed to ensure that it is 1359 // Do this even if multi-install Chrome isn't installed to ensure that it is
1356 // not left behind in any case. 1360 // not left behind in any case.
1357 work_item_list->AddDeleteRegKeyWorkItem( 1361 work_item_list->AddDeleteRegKeyWorkItem(
1358 installer_state.root_key(), cmd_key, KEY_WOW64_32KEY) 1362 installer_state.root_key(), cmd_key, KEY_WOW64_32KEY)
1359 ->set_log_message("removing " + base::UTF16ToASCII(kCmdQuickEnableCf) + 1363 ->set_log_message("removing " + base::UTF16ToASCII(kCmdQuickEnableCf) +
1360 " command"); 1364 " command");
1361 } 1365 }
1362 1366
1363 } // namespace installer 1367 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698