Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_WORK_ITEM_LIST_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ |
| 6 #define CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ | 6 #define CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 // Execute the WorkItems in the same order as they are added to the list. | 28 // Execute the WorkItems in the same order as they are added to the list. |
| 29 // It aborts as soon as one WorkItem fails. | 29 // It aborts as soon as one WorkItem fails. |
| 30 virtual bool Do(); | 30 virtual bool Do(); |
| 31 | 31 |
| 32 // Rollback the WorkItems in the reverse order as they are executed. | 32 // Rollback the WorkItems in the reverse order as they are executed. |
| 33 virtual void Rollback(); | 33 virtual void Rollback(); |
| 34 | 34 |
| 35 // Add a WorkItem to the list. | 35 // Add a WorkItem to the list. |
| 36 // A WorkItem can only be added to the list before the list's DO() is called. | 36 // A WorkItem can only be added to the list before the list's DO() is called. |
| 37 // Once a WorkItem is added to the list. The list owns the WorkItem. | 37 // Once a WorkItem is added to the list. The list owns the WorkItem. |
| 38 void AddWorkItem(WorkItem* work_item); | 38 virtual void AddWorkItem(WorkItem* work_item); |
|
erikwright (departed)
2011/01/12 16:31:49
I would prefer this to be split into a pure-virtua
amit
2011/01/12 17:41:22
+1
robertshield
2011/01/13 17:06:32
Done.
robertshield
2011/01/13 17:06:32
I completely agree, but this leads in to the WorkI
| |
| 39 | 39 |
| 40 // Add a CopyTreeWorkItem to the list of work items. | 40 // Add a CopyTreeWorkItem to the list of work items. |
| 41 WorkItem* AddCopyTreeWorkItem(const std::wstring& source_path, | 41 virtual WorkItem* AddCopyTreeWorkItem( |
| 42 const std::wstring& dest_path, | 42 const std::wstring& source_path, |
| 43 const std::wstring& temp_dir, | 43 const std::wstring& dest_path, |
| 44 CopyOverWriteOption overwrite_option, | 44 const std::wstring& temp_dir, |
| 45 const std::wstring& alternative_path = L""); | 45 CopyOverWriteOption overwrite_option, |
| 46 const std::wstring& alternative_path = L""); | |
| 46 | 47 |
| 47 // Add a CreateDirWorkItem that creates a directory at the given path. | 48 // Add a CreateDirWorkItem that creates a directory at the given path. |
| 48 WorkItem* AddCreateDirWorkItem(const FilePath& path); | 49 virtual WorkItem* AddCreateDirWorkItem(const FilePath& path); |
| 49 | 50 |
| 50 // Add a CreateRegKeyWorkItem that creates a registry key at the given | 51 // Add a CreateRegKeyWorkItem that creates a registry key at the given |
| 51 // path. | 52 // path. |
| 52 WorkItem* AddCreateRegKeyWorkItem(HKEY predefined_root, | 53 virtual WorkItem* AddCreateRegKeyWorkItem(HKEY predefined_root, |
| 53 const std::wstring& path); | 54 const std::wstring& path); |
| 54 | 55 |
| 55 // Add a DeleteRegKeyWorkItem that deletes a registry key from the given | 56 // Add a DeleteRegKeyWorkItem that deletes a registry key from the given |
| 56 // path. | 57 // path. |
| 57 WorkItem* AddDeleteRegKeyWorkItem(HKEY predefined_root, | 58 virtual WorkItem* AddDeleteRegKeyWorkItem(HKEY predefined_root, |
| 58 const std::wstring& path); | 59 const std::wstring& path); |
| 59 | 60 |
| 60 // Add a DeleteRegValueWorkItem that deletes registry value of type REG_SZ | 61 // Add a DeleteRegValueWorkItem that deletes registry value of type REG_SZ |
| 61 // or REG_DWORD. | 62 // or REG_DWORD. |
| 62 WorkItem* AddDeleteRegValueWorkItem(HKEY predefined_root, | 63 virtual WorkItem* AddDeleteRegValueWorkItem(HKEY predefined_root, |
| 63 const std::wstring& key_path, | 64 const std::wstring& key_path, |
| 64 const std::wstring& value_name, | 65 const std::wstring& value_name, |
| 65 bool is_str_type); | 66 bool is_str_type); |
| 66 | 67 |
| 67 // Add a DeleteTreeWorkItem that recursively deletes a file system | 68 // Add a DeleteTreeWorkItem that recursively deletes a file system |
| 68 // hierarchy at the given root path. A key file can be optionally specified | 69 // hierarchy at the given root path. A key file can be optionally specified |
| 69 // by key_path. | 70 // by key_path. |
| 70 WorkItem* AddDeleteTreeWorkItem(const FilePath& root_path, | 71 virtual WorkItem* AddDeleteTreeWorkItem( |
| 71 const std::vector<FilePath>& key_paths); | 72 const FilePath& root_path, |
| 73 const std::vector<FilePath>& key_paths); | |
| 72 | 74 |
| 73 // Same as above but without support for key files. | 75 // Same as above but without support for key files. |
| 74 WorkItem* AddDeleteTreeWorkItem(const FilePath& root_path); | 76 virtual WorkItem* AddDeleteTreeWorkItem(const FilePath& root_path); |
| 75 | 77 |
| 76 // Add a MoveTreeWorkItem to the list of work items. | 78 // Add a MoveTreeWorkItem to the list of work items. |
| 77 WorkItem* AddMoveTreeWorkItem(const std::wstring& source_path, | 79 virtual WorkItem* AddMoveTreeWorkItem(const std::wstring& source_path, |
| 78 const std::wstring& dest_path, | 80 const std::wstring& dest_path, |
| 79 const std::wstring& temp_dir); | 81 const std::wstring& temp_dir); |
| 80 | 82 |
| 81 // Add a SetRegValueWorkItem that sets a registry value with REG_SZ type | 83 // Add a SetRegValueWorkItem that sets a registry value with REG_SZ type |
| 82 // at the key with specified path. | 84 // at the key with specified path. |
| 83 WorkItem* AddSetRegValueWorkItem(HKEY predefined_root, | 85 virtual WorkItem* AddSetRegValueWorkItem(HKEY predefined_root, |
| 84 const std::wstring& key_path, | 86 const std::wstring& key_path, |
| 85 const std::wstring& value_name, | 87 const std::wstring& value_name, |
| 86 const std::wstring& value_data, | 88 const std::wstring& value_data, |
| 87 bool overwrite); | 89 bool overwrite); |
| 88 | 90 |
| 89 // Add a SetRegValueWorkItem that sets a registry value with REG_DWORD type | 91 // Add a SetRegValueWorkItem that sets a registry value with REG_DWORD type |
| 90 // at the key with specified path. | 92 // at the key with specified path. |
| 91 WorkItem* AddSetRegValueWorkItem(HKEY predefined_root, | 93 virtual WorkItem* AddSetRegValueWorkItem(HKEY predefined_root, |
| 92 const std::wstring& key_path, | 94 const std::wstring& key_path, |
| 93 const std::wstring& value_name, | 95 const std::wstring& value_name, |
| 94 DWORD value_data, | 96 DWORD value_data, |
| 95 bool overwrite); | 97 bool overwrite); |
| 96 | 98 |
| 97 // Add a SelfRegWorkItem that registers or unregisters a DLL at the | 99 // Add a SelfRegWorkItem that registers or unregisters a DLL at the |
| 98 // specified path. If user_level_registration is true, then alternate | 100 // specified path. If user_level_registration is true, then alternate |
| 99 // registration and unregistration entry point names will be used. | 101 // registration and unregistration entry point names will be used. |
| 100 WorkItem* AddSelfRegWorkItem(const std::wstring& dll_path, | 102 virtual WorkItem* AddSelfRegWorkItem(const std::wstring& dll_path, |
| 101 bool do_register, | 103 bool do_register, |
| 102 bool user_level_registration); | 104 bool user_level_registration); |
| 103 | 105 |
| 104 protected: | 106 protected: |
| 105 friend class WorkItem; | 107 friend class WorkItem; |
| 106 | 108 |
| 107 typedef std::list<WorkItem*> WorkItems; | 109 typedef std::list<WorkItem*> WorkItems; |
| 108 typedef WorkItems::iterator WorkItemIterator; | 110 typedef WorkItems::iterator WorkItemIterator; |
| 109 | 111 |
| 110 enum ListStatus { | 112 enum ListStatus { |
| 111 // List has not been executed. Ok to add new WorkItem. | 113 // List has not been executed. Ok to add new WorkItem. |
| 112 ADD_ITEM, | 114 ADD_ITEM, |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 139 // Execute the WorkItems in the same order as they are added to the list. | 141 // Execute the WorkItems in the same order as they are added to the list. |
| 140 // If a WorkItem fails, the function will return failure but all other | 142 // If a WorkItem fails, the function will return failure but all other |
| 141 // WorkItems will still be executed. | 143 // WorkItems will still be executed. |
| 142 virtual bool Do(); | 144 virtual bool Do(); |
| 143 | 145 |
| 144 // Just does a NOTREACHED. | 146 // Just does a NOTREACHED. |
| 145 virtual void Rollback(); | 147 virtual void Rollback(); |
| 146 }; | 148 }; |
| 147 | 149 |
| 148 #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ | 150 #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ |
| OLD | NEW |