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 // Base class for managing an action of a sequence of actions to be carried | 5 // Base class for managing an action of a sequence of actions to be carried |
6 // out during install/update/uninstall. Supports rollback of actions if this | 6 // out during install/update/uninstall. Supports rollback of actions if this |
7 // process fails. | 7 // process fails. |
8 | 8 |
9 #ifndef CHROME_INSTALLER_UTIL_WORK_ITEM_H_ | 9 #ifndef CHROME_INSTALLER_UTIL_WORK_ITEM_H_ |
10 #define CHROME_INSTALLER_UTIL_WORK_ITEM_H_ | 10 #define CHROME_INSTALLER_UTIL_WORK_ITEM_H_ |
11 | 11 |
12 #include <windows.h> | 12 #include <windows.h> |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/callback_forward.h" | 18 #include "base/callback_forward.h" |
19 | 19 |
20 class CallbackWorkItem; | 20 class CallbackWorkItem; |
21 class CopyRegKeyWorkItem; | 21 class CopyRegKeyWorkItem; |
22 class CopyTreeWorkItem; | 22 class CopyTreeWorkItem; |
23 class CreateDirWorkItem; | 23 class CreateDirWorkItem; |
24 class CreateRegKeyWorkItem; | 24 class CreateRegKeyWorkItem; |
25 class DeleteTreeWorkItem; | 25 class DeleteTreeWorkItem; |
26 class DeleteRegKeyWorkItem; | 26 class DeleteRegKeyWorkItem; |
27 class DeleteRegValueWorkItem; | 27 class DeleteRegValueWorkItem; |
28 class FilePath; | |
29 class MoveTreeWorkItem; | 28 class MoveTreeWorkItem; |
30 class SelfRegWorkItem; | 29 class SelfRegWorkItem; |
31 class SetRegValueWorkItem; | 30 class SetRegValueWorkItem; |
32 class WorkItemList; | 31 class WorkItemList; |
33 | 32 |
| 33 namespace base { |
| 34 class FilePath; |
| 35 } |
| 36 |
34 // A base class that defines APIs to perform/rollback an action or a | 37 // A base class that defines APIs to perform/rollback an action or a |
35 // sequence of actions during install/update/uninstall. | 38 // sequence of actions during install/update/uninstall. |
36 class WorkItem { | 39 class WorkItem { |
37 public: | 40 public: |
38 // Possible states | 41 // Possible states |
39 enum CopyOverWriteOption { | 42 enum CopyOverWriteOption { |
40 ALWAYS, // Always overwrite regardless of what existed before. | 43 ALWAYS, // Always overwrite regardless of what existed before. |
41 NEVER, // Not used currently. | 44 NEVER, // Not used currently. |
42 IF_DIFFERENT, // Overwrite if different. Currently only applies to file. | 45 IF_DIFFERENT, // Overwrite if different. Currently only applies to file. |
43 IF_NOT_PRESENT, // Copy only if file/directory do not exist already. | 46 IF_NOT_PRESENT, // Copy only if file/directory do not exist already. |
(...skipping 27 matching lines...) Expand all Loading... |
71 const std::wstring& dest_key_path, | 74 const std::wstring& dest_key_path, |
72 CopyOverWriteOption overwrite_option); | 75 CopyOverWriteOption overwrite_option); |
73 | 76 |
74 // Create a CopyTreeWorkItem that recursively copies a file system hierarchy | 77 // Create a CopyTreeWorkItem that recursively copies a file system hierarchy |
75 // from source path to destination path. | 78 // from source path to destination path. |
76 // * If overwrite_option is ALWAYS, the created CopyTreeWorkItem always | 79 // * If overwrite_option is ALWAYS, the created CopyTreeWorkItem always |
77 // overwrites files. | 80 // overwrites files. |
78 // * If overwrite_option is NEW_NAME_IF_IN_USE, file is copied with an | 81 // * If overwrite_option is NEW_NAME_IF_IN_USE, file is copied with an |
79 // alternate name specified by alternative_path. | 82 // alternate name specified by alternative_path. |
80 static CopyTreeWorkItem* CreateCopyTreeWorkItem( | 83 static CopyTreeWorkItem* CreateCopyTreeWorkItem( |
81 const FilePath& source_path, | 84 const base::FilePath& source_path, |
82 const FilePath& dest_path, | 85 const base::FilePath& dest_path, |
83 const FilePath& temp_dir, | 86 const base::FilePath& temp_dir, |
84 CopyOverWriteOption overwrite_option, | 87 CopyOverWriteOption overwrite_option, |
85 const FilePath& alternative_path); | 88 const base::FilePath& alternative_path); |
86 | 89 |
87 // Create a CreateDirWorkItem that creates a directory at the given path. | 90 // Create a CreateDirWorkItem that creates a directory at the given path. |
88 static CreateDirWorkItem* CreateCreateDirWorkItem(const FilePath& path); | 91 static CreateDirWorkItem* CreateCreateDirWorkItem(const base::FilePath& path); |
89 | 92 |
90 // Create a CreateRegKeyWorkItem that creates a registry key at the given | 93 // Create a CreateRegKeyWorkItem that creates a registry key at the given |
91 // path. | 94 // path. |
92 static CreateRegKeyWorkItem* CreateCreateRegKeyWorkItem( | 95 static CreateRegKeyWorkItem* CreateCreateRegKeyWorkItem( |
93 HKEY predefined_root, const std::wstring& path); | 96 HKEY predefined_root, const std::wstring& path); |
94 | 97 |
95 // Create a DeleteRegKeyWorkItem that deletes a registry key at the given | 98 // Create a DeleteRegKeyWorkItem that deletes a registry key at the given |
96 // path. | 99 // path. |
97 static DeleteRegKeyWorkItem* CreateDeleteRegKeyWorkItem( | 100 static DeleteRegKeyWorkItem* CreateDeleteRegKeyWorkItem( |
98 HKEY predefined_root, const std::wstring& path); | 101 HKEY predefined_root, const std::wstring& path); |
99 | 102 |
100 // Create a DeleteRegValueWorkItem that deletes a registry value | 103 // Create a DeleteRegValueWorkItem that deletes a registry value |
101 static DeleteRegValueWorkItem* CreateDeleteRegValueWorkItem( | 104 static DeleteRegValueWorkItem* CreateDeleteRegValueWorkItem( |
102 HKEY predefined_root, | 105 HKEY predefined_root, |
103 const std::wstring& key_path, | 106 const std::wstring& key_path, |
104 const std::wstring& value_name); | 107 const std::wstring& value_name); |
105 | 108 |
106 // Create a DeleteTreeWorkItem that recursively deletes a file system | 109 // Create a DeleteTreeWorkItem that recursively deletes a file system |
107 // hierarchy at the given root path. A key file can be optionally specified | 110 // hierarchy at the given root path. A key file can be optionally specified |
108 // by key_path. | 111 // by key_path. |
109 static DeleteTreeWorkItem* CreateDeleteTreeWorkItem( | 112 static DeleteTreeWorkItem* CreateDeleteTreeWorkItem( |
110 const FilePath& root_path, | 113 const base::FilePath& root_path, |
111 const FilePath& temp_path, | 114 const base::FilePath& temp_path, |
112 const std::vector<FilePath>& key_paths); | 115 const std::vector<base::FilePath>& key_paths); |
113 | 116 |
114 // Create a MoveTreeWorkItem that recursively moves a file system hierarchy | 117 // Create a MoveTreeWorkItem that recursively moves a file system hierarchy |
115 // from source path to destination path. | 118 // from source path to destination path. |
116 static MoveTreeWorkItem* CreateMoveTreeWorkItem( | 119 static MoveTreeWorkItem* CreateMoveTreeWorkItem( |
117 const FilePath& source_path, | 120 const base::FilePath& source_path, |
118 const FilePath& dest_path, | 121 const base::FilePath& dest_path, |
119 const FilePath& temp_dir, | 122 const base::FilePath& temp_dir, |
120 MoveTreeOption duplicate_option); | 123 MoveTreeOption duplicate_option); |
121 | 124 |
122 // Create a SetRegValueWorkItem that sets a registry value with REG_SZ type | 125 // Create a SetRegValueWorkItem that sets a registry value with REG_SZ type |
123 // at the key with specified path. | 126 // at the key with specified path. |
124 static SetRegValueWorkItem* CreateSetRegValueWorkItem( | 127 static SetRegValueWorkItem* CreateSetRegValueWorkItem( |
125 HKEY predefined_root, | 128 HKEY predefined_root, |
126 const std::wstring& key_path, | 129 const std::wstring& key_path, |
127 const std::wstring& value_name, | 130 const std::wstring& value_name, |
128 const std::wstring& value_data, | 131 const std::wstring& value_data, |
129 bool overwrite); | 132 bool overwrite); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 WorkItem(); | 203 WorkItem(); |
201 | 204 |
202 // Specifies whether this work item my fail to complete and yet still | 205 // Specifies whether this work item my fail to complete and yet still |
203 // return true from Do(). | 206 // return true from Do(). |
204 bool ignore_failure_; | 207 bool ignore_failure_; |
205 | 208 |
206 std::string log_message_; | 209 std::string log_message_; |
207 }; | 210 }; |
208 | 211 |
209 #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_H_ | 212 #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_H_ |
OLD | NEW |