Index: chrome/installer/util/delete_tree_work_item.cc |
diff --git a/chrome/installer/util/delete_tree_work_item.cc b/chrome/installer/util/delete_tree_work_item.cc |
index 7dbb9e7a618c0bef29ec83a89f4ba21e4dcddda7..9ac5313d388a653f3a88f4090ed365225b5c3f61 100644 |
--- a/chrome/installer/util/delete_tree_work_item.cc |
+++ b/chrome/installer/util/delete_tree_work_item.cc |
@@ -48,7 +48,7 @@ DeleteTreeWorkItem::~DeleteTreeWorkItem() { |
// We first try to move key_path_ to backup_path. If it succeeds, we go ahead |
// and move the rest. |
-bool DeleteTreeWorkItem::Do() { |
+bool DeleteTreeWorkItem::DoImpl() { |
// Go through all the key files and see if we can open them exclusively |
// with only the FILE_SHARE_DELETE flag. Once we know we have all of them, |
// we can delete them. |
@@ -58,7 +58,7 @@ bool DeleteTreeWorkItem::Do() { |
for (ptrdiff_t i = 0; !abort && i != num_key_files_; ++i) { |
base::FilePath& key_file = key_paths_[i]; |
base::ScopedTempDir& backup = key_backup_paths_[i]; |
- if (!ignore_failure_) { |
+ if (allow_rollback()) { |
grt (UTC plus 2)
2016/04/27 17:29:16
could you add a unittest for the no-rollback case?
fdoray
2016/05/02 20:10:00
Done.
|
if (!backup.CreateUniqueTempDirUnderPath(temp_path_)) { |
PLOG(ERROR) << "Could not create temp dir in " << temp_path_.value(); |
abort = true; |
@@ -107,34 +107,27 @@ bool DeleteTreeWorkItem::Do() { |
if (abort) { |
LOG(ERROR) << "Could not exclusively hold all key files."; |
- return ignore_failure_; |
+ return false; |
} |
// Now that we've taken care of the key files, take care of the rest. |
if (root_path_.empty() || !base::PathExists(root_path_)) |
return true; |
- if (ignore_failure_) { |
- if (DeleteRoot()) |
- return true; |
- // The file cannot be removed, but perhaps it can be moved into |
- // the temporary backup path. Consumers are responsible for making |
- // a best-effort attempt to remove the backup path. SelfCleaningTempDir |
- // is generally used for the backup path, so in the |
- // worst case the file(s) will be removed after the next reboot. |
- MoveRootToBackup(); |
+ // If rollback is not allowed, try to delete the root without making a backup. |
+ // When that fails, fall back to moving the root to the temporary backup path. |
+ // Consumers are responsible for making a best-effort attempt to remove the |
+ // backup path. SelfCleaningTempDir is generally used for the backup path, so |
+ // in the worst case the file(s) will be removed after the next reboot. |
+ if (!allow_rollback() && DeleteRoot()) |
return true; |
- } |
// Attempt to move the root to the backup. |
return MoveRootToBackup(); |
} |
// If there are files in backup paths move them back. |
-void DeleteTreeWorkItem::Rollback() { |
- if (ignore_failure_) |
- return; |
- |
+void DeleteTreeWorkItem::RollbackImpl() { |
if (moved_to_backup_) { |
base::FilePath backup = GetBackupPath(); |
DCHECK(!backup.empty()); |