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

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: fix build error Created 4 years, 7 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.
305 delete_old_archive_work_item->set_rollback_enabled(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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 setup_path, 1141 setup_path,
1138 current_version, 1142 current_version,
1139 new_version, 1143 new_version,
1140 install_list); 1144 install_list);
1141 } 1145 }
1142 1146
1143 void AddRegisterComDllWorkItems(const base::FilePath& dll_folder, 1147 void AddRegisterComDllWorkItems(const base::FilePath& dll_folder,
1144 const std::vector<base::FilePath>& dll_list, 1148 const std::vector<base::FilePath>& dll_list,
1145 bool system_level, 1149 bool system_level,
1146 bool do_register, 1150 bool do_register,
1147 bool ignore_failures, 1151 bool best_effort,
1148 WorkItemList* work_item_list) { 1152 WorkItemList* work_item_list) {
1149 DCHECK(work_item_list); 1153 DCHECK(work_item_list);
1150 if (dll_list.empty()) { 1154 if (dll_list.empty()) {
1151 VLOG(1) << "No COM DLLs to register"; 1155 VLOG(1) << "No COM DLLs to register";
1152 } else { 1156 } else {
1153 std::vector<base::FilePath>::const_iterator dll_iter(dll_list.begin()); 1157 std::vector<base::FilePath>::const_iterator dll_iter(dll_list.begin());
1154 for (; dll_iter != dll_list.end(); ++dll_iter) { 1158 for (; dll_iter != dll_list.end(); ++dll_iter) {
1155 base::FilePath dll_path = dll_folder.Append(*dll_iter); 1159 base::FilePath dll_path = dll_folder.Append(*dll_iter);
1156 WorkItem* work_item = work_item_list->AddSelfRegWorkItem( 1160 WorkItem* work_item = work_item_list->AddSelfRegWorkItem(
1157 dll_path.value(), do_register, !system_level); 1161 dll_path.value(), do_register, !system_level);
1158 DCHECK(work_item); 1162 DCHECK(work_item);
1159 work_item->set_ignore_failure(ignore_failures); 1163 work_item->set_best_effort(best_effort);
1160 } 1164 }
1161 } 1165 }
1162 } 1166 }
1163 1167
1164 void AddSetMsiMarkerWorkItem(const InstallerState& installer_state, 1168 void AddSetMsiMarkerWorkItem(const InstallerState& installer_state,
1165 BrowserDistribution* dist, 1169 BrowserDistribution* dist,
1166 bool set, 1170 bool set,
1167 WorkItemList* work_item_list) { 1171 WorkItemList* work_item_list) {
1168 DCHECK(work_item_list); 1172 DCHECK(work_item_list);
1169 DWORD msi_value = set ? 1 : 0; 1173 DWORD msi_value = set ? 1 : 0;
1170 WorkItem* set_msi_work_item = 1174 WorkItem* set_msi_work_item =
1171 work_item_list->AddSetRegValueWorkItem(installer_state.root_key(), 1175 work_item_list->AddSetRegValueWorkItem(installer_state.root_key(),
1172 dist->GetStateKey(), 1176 dist->GetStateKey(),
1173 KEY_WOW64_32KEY, 1177 KEY_WOW64_32KEY,
1174 google_update::kRegMSIField, 1178 google_update::kRegMSIField,
1175 msi_value, 1179 msi_value,
1176 true); 1180 true);
1177 DCHECK(set_msi_work_item); 1181 DCHECK(set_msi_work_item);
1178 set_msi_work_item->set_ignore_failure(true); 1182 set_msi_work_item->set_best_effort(true);
1179 set_msi_work_item->set_log_message("Could not write MSI marker!"); 1183 set_msi_work_item->set_log_message("Could not write MSI marker!");
1180 } 1184 }
1181 1185
1182 void AddCleanupDeprecatedPerUserRegistrationsWorkItems(const Product& product, 1186 void AddCleanupDeprecatedPerUserRegistrationsWorkItems(const Product& product,
1183 WorkItemList* list) { 1187 WorkItemList* list) {
1184 if (product.is_chrome()) { 1188 if (product.is_chrome()) {
1185 BrowserDistribution* dist = product.distribution(); 1189 BrowserDistribution* dist = product.distribution();
1186 1190
1187 // TODO(gab): Remove cleanup code for Metro after M53. 1191 // TODO(gab): Remove cleanup code for Metro after M53.
1188 VLOG(1) << "Adding unregistration items for per-user Metro keys."; 1192 VLOG(1) << "Adding unregistration items for per-user Metro keys.";
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 // Unconditionally remove the legacy Quick Enable command from the binaries. 1357 // Unconditionally remove the legacy Quick Enable command from the binaries.
1354 // Do this even if multi-install Chrome isn't installed to ensure that it is 1358 // Do this even if multi-install Chrome isn't installed to ensure that it is
1355 // not left behind in any case. 1359 // not left behind in any case.
1356 work_item_list->AddDeleteRegKeyWorkItem( 1360 work_item_list->AddDeleteRegKeyWorkItem(
1357 installer_state.root_key(), cmd_key, KEY_WOW64_32KEY) 1361 installer_state.root_key(), cmd_key, KEY_WOW64_32KEY)
1358 ->set_log_message("removing " + base::UTF16ToASCII(kCmdQuickEnableCf) + 1362 ->set_log_message("removing " + base::UTF16ToASCII(kCmdQuickEnableCf) +
1359 " command"); 1363 " command");
1360 } 1364 }
1361 1365
1362 } // namespace installer 1366 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698