OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_CREATE_DIR_WORK_ITEM_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_ |
6 #define CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_ | 6 #define CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "chrome/installer/util/work_item.h" | 11 #include "chrome/installer/util/work_item.h" |
12 | 12 |
13 // A WorkItem subclass that creates a directory with the specified path. | 13 // A WorkItem subclass that creates a directory with the specified path. |
14 // It also creates all necessary intermediate paths if they do not exist. | 14 // It also creates all necessary intermediate paths if they do not exist. |
15 class CreateDirWorkItem : public WorkItem { | 15 class CreateDirWorkItem : public WorkItem { |
16 public: | 16 public: |
17 ~CreateDirWorkItem() override; | 17 ~CreateDirWorkItem() override; |
18 | 18 |
| 19 bool Do() override; |
| 20 |
| 21 // Rollback tries to remove all directories created along the path. |
| 22 // If the leaf directory or one of the intermediate directories are not |
| 23 // empty, the non-empty directory and its parent directories will not be |
| 24 // removed. |
| 25 void Rollback() override; |
| 26 |
19 private: | 27 private: |
20 friend class WorkItem; | 28 friend class WorkItem; |
21 | 29 |
22 explicit CreateDirWorkItem(const base::FilePath& path); | 30 explicit CreateDirWorkItem(const base::FilePath& path); |
23 | 31 |
24 // WorkItem: | |
25 bool DoImpl() override; | |
26 | |
27 // Rollback tries to remove all directories created along the path. | |
28 // If the leaf directory or one of the intermediate directories are not | |
29 // empty, the non-empty directory and its parent directories will not be | |
30 // removed. | |
31 void RollbackImpl() override; | |
32 | |
33 // Get the top most directory that needs to be created in order to create | 32 // Get the top most directory that needs to be created in order to create |
34 // "path_", and set "top_path_" accordingly. if "path_" already exists, | 33 // "path_", and set "top_path_" accordingly. if "path_" already exists, |
35 // "top_path_" is set to empty string. | 34 // "top_path_" is set to empty string. |
36 void GetTopDirToCreate(); | 35 void GetTopDirToCreate(); |
37 | 36 |
38 // Path of the directory to be created. | 37 // Path of the directory to be created. |
39 base::FilePath path_; | 38 base::FilePath path_; |
40 | 39 |
41 // The top most directory that needs to be created. | 40 // The top most directory that needs to be created. |
42 base::FilePath top_path_; | 41 base::FilePath top_path_; |
43 | 42 |
44 bool rollback_needed_; | 43 bool rollback_needed_; |
45 }; | 44 }; |
46 | 45 |
47 #endif // CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_ | 46 #endif // CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_ |
OLD | NEW |