| 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_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 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <string> | 12 #include <map> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/string16.h" |
| 16 #include "chrome/installer/util/work_item.h" | 17 #include "chrome/installer/util/work_item.h" |
| 17 | 18 |
| 18 class FilePath; | 19 class FilePath; |
| 19 | 20 |
| 20 // A WorkItem subclass that recursively contains a list of WorkItems. Thus it | 21 // A WorkItem subclass that recursively contains a list of WorkItems. Thus it |
| 21 // provides functionalities to carry out or roll back the sequence of actions | 22 // provides functionalities to carry out or roll back the sequence of actions |
| 22 // defined by the list of WorkItems it contains. | 23 // defined by the list of WorkItems it contains. |
| 23 // The WorkItems are executed in the same order as they are added to the list. | 24 // The WorkItems are executed in the same order as they are added to the list. |
| 24 class WorkItemList : public WorkItem { | 25 class WorkItemList : public WorkItem { |
| 25 public: | 26 public: |
| 26 virtual ~WorkItemList(); | 27 virtual ~WorkItemList(); |
| 27 | 28 |
| 28 // Execute the WorkItems in the same order as they are added to the list. | 29 // Execute the WorkItems in the same order as they are added to the list. |
| 29 // It aborts as soon as one WorkItem fails. | 30 // It aborts as soon as one WorkItem fails. |
| 30 virtual bool Do(); | 31 virtual bool Do(); |
| 31 | 32 |
| 32 // Rollback the WorkItems in the reverse order as they are executed. | 33 // Rollback the WorkItems in the reverse order as they are executed. |
| 33 virtual void Rollback(); | 34 virtual void Rollback(); |
| 34 | 35 |
| 35 // Add a WorkItem to the list. | 36 // Add a WorkItem to the list. |
| 36 // A WorkItem can only be added to the list before the list's DO() is called. | 37 // 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. | 38 // Once a WorkItem is added to the list. The list owns the WorkItem. |
| 38 virtual void AddWorkItem(WorkItem* work_item); | 39 virtual void AddWorkItem(WorkItem* work_item); |
| 39 | 40 |
| 40 // Add a CopyRegKeyWorkItem that recursively copies a given registry key. | 41 // Add a CopyRegKeyWorkItem that recursively copies a given registry key. |
| 41 virtual WorkItem* AddCopyRegKeyWorkItem(HKEY predefined_root, | 42 virtual WorkItem* AddCopyRegKeyWorkItem(HKEY predefined_root, |
| 42 const std::wstring& source_key_path, | 43 const string16& source_key_path, |
| 43 const std::wstring& dest_key_path, | 44 const string16& dest_key_path, |
| 44 CopyOverWriteOption overwrite_option); | 45 CopyOverWriteOption overwrite_option); |
| 45 | 46 |
| 46 // Add a CopyTreeWorkItem to the list of work items. | 47 // Add a CopyTreeWorkItem to the list of work items. |
| 47 // See the NOTE in the documentation for the CopyTreeWorkItem class for | 48 // See the NOTE in the documentation for the CopyTreeWorkItem class for |
| 48 // special considerations regarding |temp_dir|. | 49 // special considerations regarding |temp_dir|. |
| 49 virtual WorkItem* AddCopyTreeWorkItem( | 50 virtual WorkItem* AddCopyTreeWorkItem( |
| 50 const std::wstring& source_path, | 51 const string16& source_path, |
| 51 const std::wstring& dest_path, | 52 const string16& dest_path, |
| 52 const std::wstring& temp_dir, | 53 const string16& temp_dir, |
| 53 CopyOverWriteOption overwrite_option, | 54 CopyOverWriteOption overwrite_option, |
| 54 const std::wstring& alternative_path = L""); | 55 const string16& alternative_path = L""); |
| 55 | 56 |
| 56 // Add a CreateDirWorkItem that creates a directory at the given path. | 57 // Add a CreateDirWorkItem that creates a directory at the given path. |
| 57 virtual WorkItem* AddCreateDirWorkItem(const FilePath& path); | 58 virtual WorkItem* AddCreateDirWorkItem(const FilePath& path); |
| 58 | 59 |
| 59 // Add a CreateRegKeyWorkItem that creates a registry key at the given | 60 // Add a CreateRegKeyWorkItem that creates a registry key at the given |
| 60 // path. | 61 // path. |
| 61 virtual WorkItem* AddCreateRegKeyWorkItem(HKEY predefined_root, | 62 virtual WorkItem* AddCreateRegKeyWorkItem(HKEY predefined_root, |
| 62 const std::wstring& path); | 63 const string16& path); |
| 63 | 64 |
| 64 // Add a DeleteRegKeyWorkItem that deletes a registry key from the given | 65 // Add a DeleteRegKeyWorkItem that deletes a registry key from the given |
| 65 // path. | 66 // path. |
| 66 virtual WorkItem* AddDeleteRegKeyWorkItem(HKEY predefined_root, | 67 virtual WorkItem* AddDeleteRegKeyWorkItem(HKEY predefined_root, |
| 67 const std::wstring& path); | 68 const string16& path); |
| 68 | 69 |
| 69 // Add a DeleteRegValueWorkItem that deletes registry value of type REG_SZ | 70 // Add a DeleteRegValueWorkItem that deletes registry value of type REG_SZ |
| 70 // or REG_DWORD. | 71 // or REG_DWORD. |
| 71 virtual WorkItem* AddDeleteRegValueWorkItem(HKEY predefined_root, | 72 virtual WorkItem* AddDeleteRegValueWorkItem(HKEY predefined_root, |
| 72 const std::wstring& key_path, | 73 const string16& key_path, |
| 73 const std::wstring& value_name); | 74 const string16& value_name); |
| 74 | 75 |
| 75 // Add a DeleteTreeWorkItem that recursively deletes a file system | 76 // Add a DeleteTreeWorkItem that recursively deletes a file system |
| 76 // hierarchy at the given root path. A key file can be optionally specified | 77 // hierarchy at the given root path. A key file can be optionally specified |
| 77 // by key_path. | 78 // by key_path. |
| 78 virtual WorkItem* AddDeleteTreeWorkItem( | 79 virtual WorkItem* AddDeleteTreeWorkItem( |
| 79 const FilePath& root_path, | 80 const FilePath& root_path, |
| 80 const FilePath& temp_path, | 81 const FilePath& temp_path, |
| 81 const std::vector<FilePath>& key_paths); | 82 const std::vector<FilePath>& key_paths); |
| 82 | 83 |
| 83 // Same as above but without support for key files. | 84 // Same as above but without support for key files. |
| 84 virtual WorkItem* AddDeleteTreeWorkItem(const FilePath& root_path, | 85 virtual WorkItem* AddDeleteTreeWorkItem(const FilePath& root_path, |
| 85 const FilePath& temp_path); | 86 const FilePath& temp_path); |
| 86 | 87 |
| 88 // Add a FileFromTemplateWorkItem to the list of work items. |
| 89 // |source_path| should end with the .template extension. |
| 90 virtual WorkItem* AddFileFromTemplateWorkItem( |
| 91 const string16& source_path, |
| 92 const string16& dest_path, |
| 93 const string16& temp_dir, |
| 94 const std::map<string16, string16>& mappings); |
| 95 |
| 87 // Add a MoveTreeWorkItem to the list of work items. | 96 // Add a MoveTreeWorkItem to the list of work items. |
| 88 virtual WorkItem* AddMoveTreeWorkItem(const std::wstring& source_path, | 97 virtual WorkItem* AddMoveTreeWorkItem(const string16& source_path, |
| 89 const std::wstring& dest_path, | 98 const string16& dest_path, |
| 90 const std::wstring& temp_dir, | 99 const string16& temp_dir, |
| 91 MoveTreeOption duplicate_option); | 100 MoveTreeOption duplicate_option); |
| 92 | 101 |
| 93 // Add a SetRegValueWorkItem that sets a registry value with REG_SZ type | 102 // Add a SetRegValueWorkItem that sets a registry value with REG_SZ type |
| 94 // at the key with specified path. | 103 // at the key with specified path. |
| 95 virtual WorkItem* AddSetRegValueWorkItem(HKEY predefined_root, | 104 virtual WorkItem* AddSetRegValueWorkItem(HKEY predefined_root, |
| 96 const std::wstring& key_path, | 105 const string16& key_path, |
| 97 const std::wstring& value_name, | 106 const string16& value_name, |
| 98 const std::wstring& value_data, | 107 const string16& value_data, |
| 99 bool overwrite); | 108 bool overwrite); |
| 100 | 109 |
| 101 // Add a SetRegValueWorkItem that sets a registry value with REG_DWORD type | 110 // Add a SetRegValueWorkItem that sets a registry value with REG_DWORD type |
| 102 // at the key with specified path. | 111 // at the key with specified path. |
| 103 virtual WorkItem* AddSetRegValueWorkItem(HKEY predefined_root, | 112 virtual WorkItem* AddSetRegValueWorkItem(HKEY predefined_root, |
| 104 const std::wstring& key_path, | 113 const string16& key_path, |
| 105 const std::wstring& value_name, | 114 const string16& value_name, |
| 106 DWORD value_data, | 115 DWORD value_data, |
| 107 bool overwrite); | 116 bool overwrite); |
| 108 | 117 |
| 109 // Add a SetRegValueWorkItem that sets a registry value with REG_QWORD type | 118 // Add a SetRegValueWorkItem that sets a registry value with REG_QWORD type |
| 110 // at the key with specified path. | 119 // at the key with specified path. |
| 111 virtual WorkItem* AddSetRegValueWorkItem(HKEY predefined_root, | 120 virtual WorkItem* AddSetRegValueWorkItem(HKEY predefined_root, |
| 112 const std::wstring& key_path, | 121 const string16& key_path, |
| 113 const std::wstring& value_name, | 122 const string16& value_name, |
| 114 int64 value_data, | 123 int64 value_data, |
| 115 bool overwrite); | 124 bool overwrite); |
| 116 | 125 |
| 117 // Add a SelfRegWorkItem that registers or unregisters a DLL at the | 126 // Add a SelfRegWorkItem that registers or unregisters a DLL at the |
| 118 // specified path. If user_level_registration is true, then alternate | 127 // specified path. If user_level_registration is true, then alternate |
| 119 // registration and unregistration entry point names will be used. | 128 // registration and unregistration entry point names will be used. |
| 120 virtual WorkItem* AddSelfRegWorkItem(const std::wstring& dll_path, | 129 virtual WorkItem* AddSelfRegWorkItem(const string16& dll_path, |
| 121 bool do_register, | 130 bool do_register, |
| 122 bool user_level_registration); | 131 bool user_level_registration); |
| 123 | 132 |
| 124 protected: | 133 protected: |
| 125 friend class WorkItem; | 134 friend class WorkItem; |
| 126 | 135 |
| 127 typedef std::list<WorkItem*> WorkItems; | 136 typedef std::list<WorkItem*> WorkItems; |
| 128 typedef WorkItems::iterator WorkItemIterator; | 137 typedef WorkItems::iterator WorkItemIterator; |
| 129 | 138 |
| 130 enum ListStatus { | 139 enum ListStatus { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 159 // Execute the WorkItems in the same order as they are added to the list. | 168 // Execute the WorkItems in the same order as they are added to the list. |
| 160 // If a WorkItem fails, the function will return failure but all other | 169 // If a WorkItem fails, the function will return failure but all other |
| 161 // WorkItems will still be executed. | 170 // WorkItems will still be executed. |
| 162 virtual bool Do(); | 171 virtual bool Do(); |
| 163 | 172 |
| 164 // Just does a NOTREACHED. | 173 // Just does a NOTREACHED. |
| 165 virtual void Rollback(); | 174 virtual void Rollback(); |
| 166 }; | 175 }; |
| 167 | 176 |
| 168 #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ | 177 #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ |
| OLD | NEW |