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

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

Issue 2379543002: installer and some misc files: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Fix compilation failure Created 4 years, 2 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
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 "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 DeleteTreeWorkItem::DeleteTreeWorkItem(const base::FilePath& root_path, 10 DeleteTreeWorkItem::DeleteTreeWorkItem(const base::FilePath& root_path,
(...skipping 21 matching lines...) Expand all
32 void DeleteTreeWorkItem::RollbackImpl() { 32 void DeleteTreeWorkItem::RollbackImpl() {
33 if (moved_to_backup_) { 33 if (moved_to_backup_) {
34 base::FilePath backup = GetBackupPath(); 34 base::FilePath backup = GetBackupPath();
35 DCHECK(!backup.empty()); 35 DCHECK(!backup.empty());
36 if (base::PathExists(backup)) 36 if (base::PathExists(backup))
37 base::Move(backup, root_path_); 37 base::Move(backup, root_path_);
38 } 38 }
39 } 39 }
40 40
41 base::FilePath DeleteTreeWorkItem::GetBackupPath() { 41 base::FilePath DeleteTreeWorkItem::GetBackupPath() {
42 if (backup_path_.path().empty() && 42 if (backup_path_.empty()) {
43 !backup_path_.CreateUniqueTempDirUnderPath(temp_path_)) { 43 if (!backup_dir_.CreateUniqueTempDirUnderPath(temp_path_)) {
44 PLOG(ERROR) << "Failed to get backup path in folder " << temp_path_.value(); 44 PLOG(ERROR) << "Failed to get backup path in folder "
45 return base::FilePath(); 45 << temp_path_.value();
46 return base::FilePath();
47 }
48 backup_path_ = backup_dir_.GetPath();
gab 2016/09/28 16:31:59 If we're going to have a local copy of this variab
vabr (Chromium) 2016/09/29 09:11:03 Done.
46 } 49 }
47 50
48 DCHECK(!backup_path_.path().empty()); 51 DCHECK(!backup_path_.empty());
49 return backup_path_.path().Append(root_path_.BaseName()); 52 return backup_path_.Append(root_path_.BaseName());
50 } 53 }
51 54
52 bool DeleteTreeWorkItem::DeleteRoot() { 55 bool DeleteTreeWorkItem::DeleteRoot() {
53 if (base::DeleteFile(root_path_, true)) 56 if (base::DeleteFile(root_path_, true))
54 return true; 57 return true;
55 LOG(ERROR) << "Failed to delete " << root_path_.value(); 58 LOG(ERROR) << "Failed to delete " << root_path_.value();
56 return false; 59 return false;
57 } 60 }
58 61
59 bool DeleteTreeWorkItem::MoveRootToBackup() { 62 bool DeleteTreeWorkItem::MoveRootToBackup() {
60 base::FilePath backup = GetBackupPath(); 63 base::FilePath backup = GetBackupPath();
61 if (backup.empty()) 64 if (backup.empty())
62 return false; 65 return false;
63 if (base::Move(root_path_, backup)) { 66 if (base::Move(root_path_, backup)) {
64 moved_to_backup_ = true; 67 moved_to_backup_ = true;
65 return true; 68 return true;
66 } 69 }
67 PLOG(ERROR) << "Failed to move " << root_path_.value() 70 PLOG(ERROR) << "Failed to move " << root_path_.value()
68 << " to backup path " << backup.value(); 71 << " to backup path " << backup.value();
69 return false; 72 return false;
70 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698