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 #ifndef CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ |
6 #define CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ | 6 #define CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
15 #include "chrome/installer/util/work_item.h" | 15 #include "chrome/installer/util/work_item.h" |
16 | 16 |
17 // A WorkItem subclass that recursively deletes a file system hierarchy at the | 17 // A WorkItem subclass that recursively deletes a file system hierarchy at the |
18 // given root path. The file system hierarchy could be a single file, or a | 18 // given root path. The file system hierarchy could be a single file, or a |
19 // directory. | 19 // directory. |
20 // The file system hierarchy to be deleted can have one or more key files. If | 20 // The file system hierarchy to be deleted can have one or more key files. If |
21 // specified, deletion will be performed only if all key files are not in use. | 21 // specified, deletion will be performed only if all key files are not in use. |
22 class DeleteTreeWorkItem : public WorkItem { | 22 class DeleteTreeWorkItem : public WorkItem { |
23 public: | 23 public: |
24 ~DeleteTreeWorkItem() override; | 24 ~DeleteTreeWorkItem() override; |
25 | 25 |
26 bool Do() override; | |
27 | |
28 void Rollback() override; | |
29 | |
30 private: | 26 private: |
31 friend class WorkItem; | 27 friend class WorkItem; |
32 | 28 |
33 // |root_path| will be moved to |temp_path| (rather than copied there and then | 29 // |root_path| will be moved to |temp_path| (rather than copied there and then |
34 // deleted). For best results in this case, |root_path| and |temp_path| | 30 // deleted). For best results in this case, |root_path| and |temp_path| |
35 // should be on the same volume; otherwise, the move will be simulated | 31 // should be on the same volume; otherwise, the move will be simulated |
36 // by a copy-and-delete operation. | 32 // by a copy-and-delete operation. |
37 DeleteTreeWorkItem(const base::FilePath& root_path, | 33 DeleteTreeWorkItem(const base::FilePath& root_path, |
38 const base::FilePath& temp_path, | 34 const base::FilePath& temp_path, |
39 const std::vector<base::FilePath>& key_paths); | 35 const std::vector<base::FilePath>& key_paths); |
fdoray
2016/05/02 20:10:01
|key_paths| is always empty. Can I remove the argu
grt (UTC plus 2)
2016/05/06 18:39:13
That'd be great. Unused code is just weight. We ca
fdoray
2016/05/10 18:35:28
Done.
| |
40 | 36 |
37 // WorkItem: | |
38 bool DoImpl() override; | |
39 void RollbackImpl() override; | |
40 | |
41 // Return temporary path for work based on |backup_path_| and |root_path_|. | 41 // Return temporary path for work based on |backup_path_| and |root_path_|. |
42 base::FilePath GetBackupPath(); | 42 base::FilePath GetBackupPath(); |
43 | 43 |
44 // Attempts to delete |root_path_|. Returns true on success. | 44 // Attempts to delete |root_path_|. Returns true on success. |
45 bool DeleteRoot(); | 45 bool DeleteRoot(); |
46 | 46 |
47 // Attempts to move |root_path_| to backup. Returns true on success. | 47 // Attempts to move |root_path_| to backup. Returns true on success. |
48 bool MoveRootToBackup(); | 48 bool MoveRootToBackup(); |
49 | 49 |
50 // Root path to delete. | 50 // Root path to delete. |
(...skipping 15 matching lines...) Expand all Loading... | |
66 std::unique_ptr<base::ScopedTempDir[]> key_backup_paths_; | 66 std::unique_ptr<base::ScopedTempDir[]> key_backup_paths_; |
67 | 67 |
68 // The temporary directory into which the original root_path_ has been moved. | 68 // The temporary directory into which the original root_path_ has been moved. |
69 base::ScopedTempDir backup_path_; | 69 base::ScopedTempDir backup_path_; |
70 | 70 |
71 // Set to true once root_path_ has been moved into backup_path_. | 71 // Set to true once root_path_ has been moved into backup_path_. |
72 bool moved_to_backup_; | 72 bool moved_to_backup_; |
73 }; | 73 }; |
74 | 74 |
75 #endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ | 75 #endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ |
OLD | NEW |