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

Side by Side Diff: chrome/installer/util/delete_tree_work_item.cc

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/installer/util/delete_after_reboot_helper_unittest.cc ('k') | chrome/installer/util/installer_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698