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.h" | 5 #include "chrome/installer/util/work_item.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/logging.h" | |
10 #include "chrome/installer/util/callback_work_item.h" | 9 #include "chrome/installer/util/callback_work_item.h" |
11 #include "chrome/installer/util/conditional_work_item_list.h" | 10 #include "chrome/installer/util/conditional_work_item_list.h" |
12 #include "chrome/installer/util/copy_tree_work_item.h" | 11 #include "chrome/installer/util/copy_tree_work_item.h" |
13 #include "chrome/installer/util/create_dir_work_item.h" | 12 #include "chrome/installer/util/create_dir_work_item.h" |
14 #include "chrome/installer/util/create_reg_key_work_item.h" | 13 #include "chrome/installer/util/create_reg_key_work_item.h" |
15 #include "chrome/installer/util/delete_reg_key_work_item.h" | 14 #include "chrome/installer/util/delete_reg_key_work_item.h" |
16 #include "chrome/installer/util/delete_reg_value_work_item.h" | 15 #include "chrome/installer/util/delete_reg_value_work_item.h" |
17 #include "chrome/installer/util/delete_tree_work_item.h" | 16 #include "chrome/installer/util/delete_tree_work_item.h" |
18 #include "chrome/installer/util/move_tree_work_item.h" | 17 #include "chrome/installer/util/move_tree_work_item.h" |
19 #include "chrome/installer/util/self_reg_work_item.h" | 18 #include "chrome/installer/util/self_reg_work_item.h" |
20 #include "chrome/installer/util/set_reg_value_work_item.h" | 19 #include "chrome/installer/util/set_reg_value_work_item.h" |
21 #include "chrome/installer/util/work_item_list.h" | 20 #include "chrome/installer/util/work_item_list.h" |
22 | 21 |
23 WorkItem::WorkItem() = default; | 22 WorkItem::WorkItem() : ignore_failure_(false) { |
24 WorkItem::~WorkItem() = default; | 23 } |
| 24 |
| 25 WorkItem::~WorkItem() { |
| 26 } |
25 | 27 |
26 CallbackWorkItem* WorkItem::CreateCallbackWorkItem( | 28 CallbackWorkItem* WorkItem::CreateCallbackWorkItem( |
27 base::Callback<bool(const CallbackWorkItem&)> callback) { | 29 base::Callback<bool(const CallbackWorkItem&)> callback) { |
28 return new CallbackWorkItem(callback); | 30 return new CallbackWorkItem(callback); |
29 } | 31 } |
30 | 32 |
31 CopyTreeWorkItem* WorkItem::CreateCopyTreeWorkItem( | 33 CopyTreeWorkItem* WorkItem::CreateCopyTreeWorkItem( |
32 const base::FilePath& source_path, | 34 const base::FilePath& source_path, |
33 const base::FilePath& dest_path, | 35 const base::FilePath& dest_path, |
34 const base::FilePath& temp_dir, | 36 const base::FilePath& temp_dir, |
(...skipping 26 matching lines...) Expand all Loading... |
61 HKEY predefined_root, | 63 HKEY predefined_root, |
62 const std::wstring& key_path, | 64 const std::wstring& key_path, |
63 REGSAM wow64_access, | 65 REGSAM wow64_access, |
64 const std::wstring& value_name) { | 66 const std::wstring& value_name) { |
65 return new DeleteRegValueWorkItem( | 67 return new DeleteRegValueWorkItem( |
66 predefined_root, key_path, wow64_access, value_name); | 68 predefined_root, key_path, wow64_access, value_name); |
67 } | 69 } |
68 | 70 |
69 DeleteTreeWorkItem* WorkItem::CreateDeleteTreeWorkItem( | 71 DeleteTreeWorkItem* WorkItem::CreateDeleteTreeWorkItem( |
70 const base::FilePath& root_path, | 72 const base::FilePath& root_path, |
71 const base::FilePath& temp_path) { | 73 const base::FilePath& temp_path, |
72 return new DeleteTreeWorkItem(root_path, temp_path); | 74 const std::vector<base::FilePath>& key_paths) { |
| 75 return new DeleteTreeWorkItem(root_path, temp_path, key_paths); |
73 } | 76 } |
74 | 77 |
75 MoveTreeWorkItem* WorkItem::CreateMoveTreeWorkItem( | 78 MoveTreeWorkItem* WorkItem::CreateMoveTreeWorkItem( |
76 const base::FilePath& source_path, | 79 const base::FilePath& source_path, |
77 const base::FilePath& dest_path, | 80 const base::FilePath& dest_path, |
78 const base::FilePath& temp_dir, | 81 const base::FilePath& temp_dir, |
79 MoveTreeOption duplicate_option) { | 82 MoveTreeOption duplicate_option) { |
80 return new MoveTreeWorkItem(source_path, | 83 return new MoveTreeWorkItem(source_path, |
81 dest_path, | 84 dest_path, |
82 temp_dir, | 85 temp_dir, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 SelfRegWorkItem* WorkItem::CreateSelfRegWorkItem(const std::wstring& dll_path, | 147 SelfRegWorkItem* WorkItem::CreateSelfRegWorkItem(const std::wstring& dll_path, |
145 bool do_register, | 148 bool do_register, |
146 bool user_level_registration) { | 149 bool user_level_registration) { |
147 return new SelfRegWorkItem(dll_path, do_register, user_level_registration); | 150 return new SelfRegWorkItem(dll_path, do_register, user_level_registration); |
148 } | 151 } |
149 | 152 |
150 WorkItemList* WorkItem::CreateWorkItemList() { | 153 WorkItemList* WorkItem::CreateWorkItemList() { |
151 return new WorkItemList(); | 154 return new WorkItemList(); |
152 } | 155 } |
153 | 156 |
| 157 // static |
| 158 WorkItemList* WorkItem::CreateNoRollbackWorkItemList() { |
| 159 return new NoRollbackWorkItemList(); |
| 160 } |
| 161 |
154 WorkItemList* WorkItem::CreateConditionalWorkItemList(Condition* condition) { | 162 WorkItemList* WorkItem::CreateConditionalWorkItemList(Condition* condition) { |
155 return new ConditionalWorkItemList(condition); | 163 return new ConditionalWorkItemList(condition); |
156 } | 164 } |
157 | |
158 bool WorkItem::Do() { | |
159 DCHECK_EQ(BEFORE_DO, state_); | |
160 const bool success = DoImpl(); | |
161 state_ = AFTER_DO; | |
162 return best_effort() ? true : success; | |
163 } | |
164 | |
165 void WorkItem::Rollback() { | |
166 DCHECK_EQ(AFTER_DO, state_); | |
167 if (rollback_enabled()) | |
168 RollbackImpl(); | |
169 state_ = AFTER_ROLLBACK; | |
170 } | |
171 | |
172 void WorkItem::set_best_effort(bool best_effort) { | |
173 DCHECK_EQ(BEFORE_DO, state()); | |
174 best_effort_ = best_effort; | |
175 } | |
176 | |
177 void WorkItem::set_rollback_enabled(bool rollback_enabled) { | |
178 DCHECK_EQ(BEFORE_DO, state()); | |
179 rollback_enabled_ = rollback_enabled; | |
180 } | |
OLD | NEW |