| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/util/delete_tree_work_item.h" | 5 #include "chrome/installer/util/delete_tree_work_item.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 if (!abort) { | 88 if (!abort) { |
| 89 // We now hold exclusive locks with "share delete" permissions for each | 89 // We now hold exclusive locks with "share delete" permissions for each |
| 90 // of the key files and also have created backups of those files. | 90 // of the key files and also have created backups of those files. |
| 91 // We can safely delete the key files now. | 91 // We can safely delete the key files now. |
| 92 for (ptrdiff_t i = 0; !abort && i != num_key_files_; ++i) { | 92 for (ptrdiff_t i = 0; !abort && i != num_key_files_; ++i) { |
| 93 base::FilePath& key_file = key_paths_[i]; | 93 base::FilePath& key_file = key_paths_[i]; |
| 94 if (!file_util::Delete(key_file, true)) { | 94 if (!base::Delete(key_file, true)) { |
| 95 // This should not really be possible because of the above. | 95 // This should not really be possible because of the above. |
| 96 PLOG(DFATAL) << "Unexpectedly could not delete " << key_file.value(); | 96 PLOG(DFATAL) << "Unexpectedly could not delete " << key_file.value(); |
| 97 abort = true; | 97 abort = true; |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 std::for_each(opened_key_files.begin(), opened_key_files.end(), CloseHandle); | 102 std::for_each(opened_key_files.begin(), opened_key_files.end(), CloseHandle); |
| 103 opened_key_files.clear(); | 103 opened_key_files.clear(); |
| 104 | 104 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 119 backup_path_.path().Append(root_path_.BaseName()); | 119 backup_path_.path().Append(root_path_.BaseName()); |
| 120 if (!file_util::CopyDirectory(root_path_, backup, true)) { | 120 if (!file_util::CopyDirectory(root_path_, backup, true)) { |
| 121 LOG(ERROR) << "can not copy " << root_path_.value() | 121 LOG(ERROR) << "can not copy " << root_path_.value() |
| 122 << " to backup path " << backup.value(); | 122 << " to backup path " << backup.value(); |
| 123 return false; | 123 return false; |
| 124 } else { | 124 } else { |
| 125 copied_to_backup_ = true; | 125 copied_to_backup_ = true; |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 if (!file_util::Delete(root_path_, true)) { | 129 if (!base::Delete(root_path_, true)) { |
| 130 LOG(ERROR) << "can not delete " << root_path_.value(); | 130 LOG(ERROR) << "can not delete " << root_path_.value(); |
| 131 return ignore_failure_; | 131 return ignore_failure_; |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 return true; | 135 return true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 // If there are files in backup paths move them back. | 138 // If there are files in backup paths move them back. |
| 139 void DeleteTreeWorkItem::Rollback() { | 139 void DeleteTreeWorkItem::Rollback() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 155 backup_dir.path().Append(key_file.BaseName()); | 155 backup_dir.path().Append(key_file.BaseName()); |
| 156 if (file_util::PathExists(backup_file) && | 156 if (file_util::PathExists(backup_file) && |
| 157 !file_util::Move(backup_file, key_file)) { | 157 !file_util::Move(backup_file, key_file)) { |
| 158 // This could happen if we could not delete the key file to begin with. | 158 // This could happen if we could not delete the key file to begin with. |
| 159 PLOG(WARNING) << "Rollback: Failed to move backup file back in place: " | 159 PLOG(WARNING) << "Rollback: Failed to move backup file back in place: " |
| 160 << backup_file.value() << " to " << key_file.value(); | 160 << backup_file.value() << " to " << key_file.value(); |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 } | 164 } |
| OLD | NEW |