| 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 #include "chrome/installer/util/work_item_list.h" | 5 #include "chrome/installer/util/work_item_list.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "chrome/installer/util/logging_installer.h" | 9 #include "chrome/installer/util/logging_installer.h" |
| 10 #include "chrome/installer/util/copy_reg_key_work_item.h" | 10 #include "chrome/installer/util/copy_reg_key_work_item.h" |
| 11 #include "chrome/installer/util/copy_tree_work_item.h" | 11 #include "chrome/installer/util/copy_tree_work_item.h" |
| 12 #include "chrome/installer/util/create_dir_work_item.h" | 12 #include "chrome/installer/util/create_dir_work_item.h" |
| 13 #include "chrome/installer/util/create_reg_key_work_item.h" | 13 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 14 #include "chrome/installer/util/delete_tree_work_item.h" | 14 #include "chrome/installer/util/delete_tree_work_item.h" |
| 15 #include "chrome/installer/util/delete_reg_key_work_item.h" | 15 #include "chrome/installer/util/delete_reg_key_work_item.h" |
| 16 #include "chrome/installer/util/delete_reg_value_work_item.h" | 16 #include "chrome/installer/util/delete_reg_value_work_item.h" |
| 17 #include "chrome/installer/util/file_from_template_work_item.h" |
| 17 #include "chrome/installer/util/move_tree_work_item.h" | 18 #include "chrome/installer/util/move_tree_work_item.h" |
| 18 #include "chrome/installer/util/self_reg_work_item.h" | 19 #include "chrome/installer/util/self_reg_work_item.h" |
| 19 #include "chrome/installer/util/set_reg_value_work_item.h" | 20 #include "chrome/installer/util/set_reg_value_work_item.h" |
| 20 | 21 |
| 21 WorkItemList::~WorkItemList() { | 22 WorkItemList::~WorkItemList() { |
| 22 for (WorkItemIterator itr = list_.begin(); itr != list_.end(); ++itr) { | 23 for (WorkItemIterator itr = list_.begin(); itr != list_.end(); ++itr) { |
| 23 delete (*itr); | 24 delete (*itr); |
| 24 } | 25 } |
| 25 for (WorkItemIterator itr = executed_list_.begin(); | 26 for (WorkItemIterator itr = executed_list_.begin(); |
| 26 itr != executed_list_.end(); ++itr) { | 27 itr != executed_list_.end(); ++itr) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return; | 69 return; |
| 69 } | 70 } |
| 70 | 71 |
| 71 void WorkItemList::AddWorkItem(WorkItem* work_item) { | 72 void WorkItemList::AddWorkItem(WorkItem* work_item) { |
| 72 DCHECK(status_ == ADD_ITEM); | 73 DCHECK(status_ == ADD_ITEM); |
| 73 list_.push_back(work_item); | 74 list_.push_back(work_item); |
| 74 } | 75 } |
| 75 | 76 |
| 76 WorkItem* WorkItemList::AddCopyRegKeyWorkItem( | 77 WorkItem* WorkItemList::AddCopyRegKeyWorkItem( |
| 77 HKEY predefined_root, | 78 HKEY predefined_root, |
| 78 const std::wstring& source_key_path, | 79 const string16& source_key_path, |
| 79 const std::wstring& dest_key_path, | 80 const string16& dest_key_path, |
| 80 CopyOverWriteOption overwrite_option) { | 81 CopyOverWriteOption overwrite_option) { |
| 81 WorkItem* item = WorkItem::CreateCopyRegKeyWorkItem( | 82 WorkItem* item = WorkItem::CreateCopyRegKeyWorkItem( |
| 82 predefined_root, source_key_path, dest_key_path, overwrite_option); | 83 predefined_root, source_key_path, dest_key_path, overwrite_option); |
| 83 AddWorkItem(item); | 84 AddWorkItem(item); |
| 84 return item; | 85 return item; |
| 85 } | 86 } |
| 86 | 87 |
| 87 WorkItem* WorkItemList::AddCopyTreeWorkItem( | 88 WorkItem* WorkItemList::AddCopyTreeWorkItem( |
| 88 const std::wstring& source_path, | 89 const string16& source_path, |
| 89 const std::wstring& dest_path, | 90 const string16& dest_path, |
| 90 const std::wstring& temp_dir, | 91 const string16& temp_dir, |
| 91 CopyOverWriteOption overwrite_option, | 92 CopyOverWriteOption overwrite_option, |
| 92 const std::wstring& alternative_path) { | 93 const string16& alternative_path) { |
| 93 WorkItem* item = WorkItem::CreateCopyTreeWorkItem(FilePath(source_path), | 94 WorkItem* item = WorkItem::CreateCopyTreeWorkItem(FilePath(source_path), |
| 94 FilePath(dest_path), | 95 FilePath(dest_path), |
| 95 FilePath(temp_dir), | 96 FilePath(temp_dir), |
| 96 overwrite_option, | 97 overwrite_option, |
| 97 FilePath(alternative_path)); | 98 FilePath(alternative_path)); |
| 98 AddWorkItem(item); | 99 AddWorkItem(item); |
| 99 return item; | 100 return item; |
| 100 } | 101 } |
| 101 | 102 |
| 102 WorkItem* WorkItemList::AddCreateDirWorkItem(const FilePath& path) { | 103 WorkItem* WorkItemList::AddCreateDirWorkItem(const FilePath& path) { |
| 103 WorkItem* item = WorkItem::CreateCreateDirWorkItem(path); | 104 WorkItem* item = WorkItem::CreateCreateDirWorkItem(path); |
| 104 AddWorkItem(item); | 105 AddWorkItem(item); |
| 105 return item; | 106 return item; |
| 106 } | 107 } |
| 107 | 108 |
| 108 WorkItem* WorkItemList::AddCreateRegKeyWorkItem(HKEY predefined_root, | 109 WorkItem* WorkItemList::AddCreateRegKeyWorkItem(HKEY predefined_root, |
| 109 const std::wstring& path) { | 110 const string16& path) { |
| 110 WorkItem* item = WorkItem::CreateCreateRegKeyWorkItem(predefined_root, path); | 111 WorkItem* item = WorkItem::CreateCreateRegKeyWorkItem(predefined_root, path); |
| 111 AddWorkItem(item); | 112 AddWorkItem(item); |
| 112 return item; | 113 return item; |
| 113 } | 114 } |
| 114 | 115 |
| 115 WorkItem* WorkItemList::AddDeleteRegKeyWorkItem(HKEY predefined_root, | 116 WorkItem* WorkItemList::AddDeleteRegKeyWorkItem(HKEY predefined_root, |
| 116 const std::wstring& path) { | 117 const string16& path) { |
| 117 WorkItem* item = WorkItem::CreateDeleteRegKeyWorkItem(predefined_root, path); | 118 WorkItem* item = WorkItem::CreateDeleteRegKeyWorkItem(predefined_root, path); |
| 118 AddWorkItem(item); | 119 AddWorkItem(item); |
| 119 return item; | 120 return item; |
| 120 } | 121 } |
| 121 | 122 |
| 122 WorkItem* WorkItemList::AddDeleteRegValueWorkItem( | 123 WorkItem* WorkItemList::AddDeleteRegValueWorkItem( |
| 123 HKEY predefined_root, | 124 HKEY predefined_root, |
| 124 const std::wstring& key_path, | 125 const string16& key_path, |
| 125 const std::wstring& value_name) { | 126 const string16& value_name) { |
| 126 WorkItem* item = WorkItem::CreateDeleteRegValueWorkItem(predefined_root, | 127 WorkItem* item = WorkItem::CreateDeleteRegValueWorkItem(predefined_root, |
| 127 key_path, value_name); | 128 key_path, value_name); |
| 128 AddWorkItem(item); | 129 AddWorkItem(item); |
| 129 return item; | 130 return item; |
| 130 } | 131 } |
| 131 | 132 |
| 132 WorkItem* WorkItemList::AddDeleteTreeWorkItem( | 133 WorkItem* WorkItemList::AddDeleteTreeWorkItem( |
| 133 const FilePath& root_path, | 134 const FilePath& root_path, |
| 134 const FilePath& temp_path, | 135 const FilePath& temp_path, |
| 135 const std::vector<FilePath>& key_paths) { | 136 const std::vector<FilePath>& key_paths) { |
| 136 WorkItem* item = WorkItem::CreateDeleteTreeWorkItem(root_path, temp_path, | 137 WorkItem* item = WorkItem::CreateDeleteTreeWorkItem(root_path, temp_path, |
| 137 key_paths); | 138 key_paths); |
| 138 AddWorkItem(item); | 139 AddWorkItem(item); |
| 139 return item; | 140 return item; |
| 140 } | 141 } |
| 141 | 142 |
| 142 WorkItem* WorkItemList::AddDeleteTreeWorkItem(const FilePath& root_path, | 143 WorkItem* WorkItemList::AddDeleteTreeWorkItem(const FilePath& root_path, |
| 143 const FilePath& temp_path) { | 144 const FilePath& temp_path) { |
| 144 std::vector<FilePath> no_key_files; | 145 std::vector<FilePath> no_key_files; |
| 145 return AddDeleteTreeWorkItem(root_path, temp_path, no_key_files); | 146 return AddDeleteTreeWorkItem(root_path, temp_path, no_key_files); |
| 146 } | 147 } |
| 147 | 148 |
| 148 WorkItem* WorkItemList::AddMoveTreeWorkItem(const std::wstring& source_path, | 149 WorkItem* WorkItemList::AddFileFromTemplateWorkItem( |
| 149 const std::wstring& dest_path, | 150 const string16& source_path, |
| 150 const std::wstring& temp_dir, | 151 const string16& dest_path, |
| 152 const string16& temp_dir, |
| 153 const std::map<string16, string16>& mappings) { |
| 154 WorkItem* item = WorkItem::CreateFileFromTemplateWorkItem( |
| 155 FilePath(source_path), |
| 156 FilePath(dest_path), |
| 157 FilePath(temp_dir), |
| 158 mappings); |
| 159 AddWorkItem(item); |
| 160 return item; |
| 161 } |
| 162 |
| 163 WorkItem* WorkItemList::AddMoveTreeWorkItem(const string16& source_path, |
| 164 const string16& dest_path, |
| 165 const string16& temp_dir, |
| 151 MoveTreeOption duplicate_option) { | 166 MoveTreeOption duplicate_option) { |
| 152 WorkItem* item = WorkItem::CreateMoveTreeWorkItem(FilePath(source_path), | 167 WorkItem* item = WorkItem::CreateMoveTreeWorkItem(FilePath(source_path), |
| 153 FilePath(dest_path), | 168 FilePath(dest_path), |
| 154 FilePath(temp_dir), | 169 FilePath(temp_dir), |
| 155 duplicate_option); | 170 duplicate_option); |
| 156 AddWorkItem(item); | 171 AddWorkItem(item); |
| 157 return item; | 172 return item; |
| 158 } | 173 } |
| 159 | 174 |
| 160 WorkItem* WorkItemList::AddSetRegValueWorkItem( | 175 WorkItem* WorkItemList::AddSetRegValueWorkItem( |
| 161 HKEY predefined_root, | 176 HKEY predefined_root, |
| 162 const std::wstring& key_path, | 177 const string16& key_path, |
| 163 const std::wstring& value_name, | 178 const string16& value_name, |
| 164 const std::wstring& value_data, | 179 const string16& value_data, |
| 165 bool overwrite) { | 180 bool overwrite) { |
| 166 WorkItem* item = WorkItem::CreateSetRegValueWorkItem(predefined_root, | 181 WorkItem* item = WorkItem::CreateSetRegValueWorkItem(predefined_root, |
| 167 key_path, | 182 key_path, |
| 168 value_name, | 183 value_name, |
| 169 value_data, | 184 value_data, |
| 170 overwrite); | 185 overwrite); |
| 171 AddWorkItem(item); | 186 AddWorkItem(item); |
| 172 return item; | 187 return item; |
| 173 } | 188 } |
| 174 | 189 |
| 175 WorkItem* WorkItemList::AddSetRegValueWorkItem(HKEY predefined_root, | 190 WorkItem* WorkItemList::AddSetRegValueWorkItem(HKEY predefined_root, |
| 176 const std::wstring& key_path, | 191 const string16& key_path, |
| 177 const std::wstring& value_name, | 192 const string16& value_name, |
| 178 DWORD value_data, | 193 DWORD value_data, |
| 179 bool overwrite) { | 194 bool overwrite) { |
| 180 WorkItem* item = WorkItem::CreateSetRegValueWorkItem(predefined_root, | 195 WorkItem* item = WorkItem::CreateSetRegValueWorkItem(predefined_root, |
| 181 key_path, | 196 key_path, |
| 182 value_name, | 197 value_name, |
| 183 value_data, | 198 value_data, |
| 184 overwrite); | 199 overwrite); |
| 185 AddWorkItem(item); | 200 AddWorkItem(item); |
| 186 return item; | 201 return item; |
| 187 } | 202 } |
| 188 | 203 |
| 189 WorkItem* WorkItemList::AddSetRegValueWorkItem(HKEY predefined_root, | 204 WorkItem* WorkItemList::AddSetRegValueWorkItem(HKEY predefined_root, |
| 190 const std::wstring& key_path, | 205 const string16& key_path, |
| 191 const std::wstring& value_name, | 206 const string16& value_name, |
| 192 int64 value_data, | 207 int64 value_data, |
| 193 bool overwrite) { | 208 bool overwrite) { |
| 194 WorkItem* item = reinterpret_cast<WorkItem*>( | 209 WorkItem* item = reinterpret_cast<WorkItem*>( |
| 195 WorkItem::CreateSetRegValueWorkItem(predefined_root, key_path, value_name, | 210 WorkItem::CreateSetRegValueWorkItem(predefined_root, key_path, value_name, |
| 196 value_data, overwrite)); | 211 value_data, overwrite)); |
| 197 AddWorkItem(item); | 212 AddWorkItem(item); |
| 198 return item; | 213 return item; |
| 199 } | 214 } |
| 200 | 215 |
| 201 WorkItem* WorkItemList::AddSelfRegWorkItem(const std::wstring& dll_path, | 216 WorkItem* WorkItemList::AddSelfRegWorkItem(const string16& dll_path, |
| 202 bool do_register, | 217 bool do_register, |
| 203 bool user_level_registration) { | 218 bool user_level_registration) { |
| 204 WorkItem* item = WorkItem::CreateSelfRegWorkItem(dll_path, do_register, | 219 WorkItem* item = WorkItem::CreateSelfRegWorkItem(dll_path, do_register, |
| 205 user_level_registration); | 220 user_level_registration); |
| 206 AddWorkItem(item); | 221 AddWorkItem(item); |
| 207 return item; | 222 return item; |
| 208 } | 223 } |
| 209 | 224 |
| 210 //////////////////////////////////////////////////////////////////////////////// | 225 //////////////////////////////////////////////////////////////////////////////// |
| 211 NoRollbackWorkItemList::~NoRollbackWorkItemList() { | 226 NoRollbackWorkItemList::~NoRollbackWorkItemList() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 231 if (result) | 246 if (result) |
| 232 VLOG(1) << "NoRollbackWorkItemList: list execution succeeded"; | 247 VLOG(1) << "NoRollbackWorkItemList: list execution succeeded"; |
| 233 | 248 |
| 234 status_ = LIST_EXECUTED; | 249 status_ = LIST_EXECUTED; |
| 235 return result; | 250 return result; |
| 236 } | 251 } |
| 237 | 252 |
| 238 void NoRollbackWorkItemList::Rollback() { | 253 void NoRollbackWorkItemList::Rollback() { |
| 239 NOTREACHED() << "Can't rollback a NoRollbackWorkItemList"; | 254 NOTREACHED() << "Can't rollback a NoRollbackWorkItemList"; |
| 240 } | 255 } |
| OLD | NEW |