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

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

Issue 18332014: Move Copy* into the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 std::vector<HANDLE> opened_key_files; 55 std::vector<HANDLE> opened_key_files;
56 opened_key_files.reserve(num_key_files_); 56 opened_key_files.reserve(num_key_files_);
57 bool abort = false; 57 bool abort = false;
58 for (ptrdiff_t i = 0; !abort && i != num_key_files_; ++i) { 58 for (ptrdiff_t i = 0; !abort && i != num_key_files_; ++i) {
59 base::FilePath& key_file = key_paths_[i]; 59 base::FilePath& key_file = key_paths_[i];
60 base::ScopedTempDir& backup = key_backup_paths_[i]; 60 base::ScopedTempDir& backup = key_backup_paths_[i];
61 if (!ignore_failure_) { 61 if (!ignore_failure_) {
62 if (!backup.CreateUniqueTempDirUnderPath(temp_path_)) { 62 if (!backup.CreateUniqueTempDirUnderPath(temp_path_)) {
63 PLOG(ERROR) << "Could not create temp dir in " << temp_path_.value(); 63 PLOG(ERROR) << "Could not create temp dir in " << temp_path_.value();
64 abort = true; 64 abort = true;
65 } else if (!file_util::CopyFile(key_file, 65 } else if (!base::CopyFile(key_file,
66 backup.path().Append(key_file.BaseName()))) { 66 backup.path().Append(key_file.BaseName()))) {
67 PLOG(ERROR) << "Could not back up " << key_file.value() 67 PLOG(ERROR) << "Could not back up " << key_file.value()
68 << " to directory " << backup.path().value(); 68 << " to directory " << backup.path().value();
69 abort = true; 69 abort = true;
70 backup.Delete(); 70 backup.Delete();
71 } 71 }
72 } 72 }
73 if (!abort) { 73 if (!abort) {
74 HANDLE file = ::CreateFile(key_file.value().c_str(), FILE_ALL_ACCESS, 74 HANDLE file = ::CreateFile(key_file.value().c_str(), FILE_ALL_ACCESS,
75 FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, 75 FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // Now that we've taken care of the key files, take care of the rest. 110 // Now that we've taken care of the key files, take care of the rest.
111 if (!root_path_.empty() && file_util::PathExists(root_path_)) { 111 if (!root_path_.empty() && file_util::PathExists(root_path_)) {
112 if (!ignore_failure_) { 112 if (!ignore_failure_) {
113 if (!backup_path_.CreateUniqueTempDirUnderPath(temp_path_)) { 113 if (!backup_path_.CreateUniqueTempDirUnderPath(temp_path_)) {
114 PLOG(ERROR) << "Failed to get backup path in folder " 114 PLOG(ERROR) << "Failed to get backup path in folder "
115 << temp_path_.value(); 115 << temp_path_.value();
116 return false; 116 return false;
117 } else { 117 } else {
118 base::FilePath backup = 118 base::FilePath backup =
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 (!base::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 (!base::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();
(...skipping 24 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 !base::Move(backup_file, key_file)) { 157 !base::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/copy_tree_work_item_unittest.cc ('k') | chrome/installer/util/delete_tree_work_item_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698