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

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

Issue 18383003: Move DeleteAfterReboot and Move to 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
« no previous file with comments | « chrome/installer/util/logging_installer.cc ('k') | chrome/test/reliability/page_load_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/move_tree_work_item.h" 5 #include "chrome/installer/util/move_tree_work_item.h"
6 6
7 #include <shlwapi.h> 7 #include <shlwapi.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 << temp_dir_.value(); 48 << temp_dir_.value();
49 return false; 49 return false;
50 } 50 }
51 base::FilePath backup = backup_path_.path().Append(dest_path_.BaseName()); 51 base::FilePath backup = backup_path_.path().Append(dest_path_.BaseName());
52 52
53 if (duplicate_option_ == CHECK_DUPLICATES) { 53 if (duplicate_option_ == CHECK_DUPLICATES) {
54 if (installer::IsIdenticalFileHierarchy(source_path_, dest_path_)) { 54 if (installer::IsIdenticalFileHierarchy(source_path_, dest_path_)) {
55 // The files we are moving are already present in the destination path. 55 // The files we are moving are already present in the destination path.
56 // We most likely don't need to do anything. As such, just move the 56 // We most likely don't need to do anything. As such, just move the
57 // source files to the temp folder as backup. 57 // source files to the temp folder as backup.
58 if (file_util::Move(source_path_, backup)) { 58 if (base::Move(source_path_, backup)) {
59 source_moved_to_backup_ = true; 59 source_moved_to_backup_ = true;
60 VLOG(1) << "Moved source " << source_path_.value() 60 VLOG(1) << "Moved source " << source_path_.value()
61 << " to backup path " << backup.value(); 61 << " to backup path " << backup.value();
62 return true; 62 return true;
63 } else { 63 } else {
64 // We failed to move the source tree to the backup path. This is odd 64 // We failed to move the source tree to the backup path. This is odd
65 // but just fall through and attempt the regular behaviour as well. 65 // but just fall through and attempt the regular behaviour as well.
66 LOG(ERROR) << "Failed to backup source " << source_path_.value() 66 LOG(ERROR) << "Failed to backup source " << source_path_.value()
67 << " to backup path " << backup.value() 67 << " to backup path " << backup.value()
68 << " for duplicate trees. Trying regular Move instead."; 68 << " for duplicate trees. Trying regular Move instead.";
69 } 69 }
70 } else { 70 } else {
71 VLOG(1) << "Source path " << source_path_.value() 71 VLOG(1) << "Source path " << source_path_.value()
72 << " differs from " << dest_path_.value() 72 << " differs from " << dest_path_.value()
73 << ", updating now."; 73 << ", updating now.";
74 } 74 }
75 } 75 }
76 76
77 if (file_util::Move(dest_path_, backup)) { 77 if (base::Move(dest_path_, backup)) {
78 moved_to_backup_ = true; 78 moved_to_backup_ = true;
79 VLOG(1) << "Moved destination " << dest_path_.value() 79 VLOG(1) << "Moved destination " << dest_path_.value()
80 << " to backup path " << backup.value(); 80 << " to backup path " << backup.value();
81 } else { 81 } else {
82 PLOG(ERROR) << "failed moving " << dest_path_.value() 82 PLOG(ERROR) << "failed moving " << dest_path_.value()
83 << " to " << backup.value(); 83 << " to " << backup.value();
84 return false; 84 return false;
85 } 85 }
86 } 86 }
87 87
88 // Now move source to destination. 88 // Now move source to destination.
89 if (file_util::Move(source_path_, dest_path_)) { 89 if (base::Move(source_path_, dest_path_)) {
90 moved_to_dest_path_ = true; 90 moved_to_dest_path_ = true;
91 VLOG(1) << "Moved source " << source_path_.value() 91 VLOG(1) << "Moved source " << source_path_.value()
92 << " to destination " << dest_path_.value(); 92 << " to destination " << dest_path_.value();
93 } else { 93 } else {
94 PLOG(ERROR) << "failed move " << source_path_.value() 94 PLOG(ERROR) << "failed move " << source_path_.value()
95 << " to " << dest_path_.value(); 95 << " to " << dest_path_.value();
96 return false; 96 return false;
97 } 97 }
98 98
99 return true; 99 return true;
100 } 100 }
101 101
102 void MoveTreeWorkItem::Rollback() { 102 void MoveTreeWorkItem::Rollback() {
103 if (moved_to_dest_path_ && !file_util::Move(dest_path_, source_path_)) 103 if (moved_to_dest_path_ && !base::Move(dest_path_, source_path_))
104 LOG(ERROR) << "Can not move " << dest_path_.value() 104 LOG(ERROR) << "Can not move " << dest_path_.value()
105 << " to " << source_path_.value(); 105 << " to " << source_path_.value();
106 106
107 base::FilePath backup = backup_path_.path().Append(dest_path_.BaseName()); 107 base::FilePath backup = backup_path_.path().Append(dest_path_.BaseName());
108 if (moved_to_backup_ && !file_util::Move(backup, dest_path_)) { 108 if (moved_to_backup_ && !base::Move(backup, dest_path_)) {
109 LOG(ERROR) << "failed move " << backup.value() 109 LOG(ERROR) << "failed move " << backup.value()
110 << " to " << dest_path_.value(); 110 << " to " << dest_path_.value();
111 } 111 }
112 112
113 if (source_moved_to_backup_ && !file_util::Move(backup, source_path_)) { 113 if (source_moved_to_backup_ && !base::Move(backup, source_path_)) {
114 LOG(ERROR) << "Can not restore " << backup.value() 114 LOG(ERROR) << "Can not restore " << backup.value()
115 << " to " << source_path_.value(); 115 << " to " << source_path_.value();
116 } 116 }
117 } 117 }
OLDNEW
« no previous file with comments | « chrome/installer/util/logging_installer.cc ('k') | chrome/test/reliability/page_load_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698