Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/installer/util/work_item.cc

Issue 1882923003: Add best-effort/allow rollback flags on WorkItem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simple_list_tests
Patch Set: fix build error Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
9 #include "chrome/installer/util/callback_work_item.h" 10 #include "chrome/installer/util/callback_work_item.h"
10 #include "chrome/installer/util/conditional_work_item_list.h" 11 #include "chrome/installer/util/conditional_work_item_list.h"
11 #include "chrome/installer/util/copy_tree_work_item.h" 12 #include "chrome/installer/util/copy_tree_work_item.h"
12 #include "chrome/installer/util/create_dir_work_item.h" 13 #include "chrome/installer/util/create_dir_work_item.h"
13 #include "chrome/installer/util/create_reg_key_work_item.h" 14 #include "chrome/installer/util/create_reg_key_work_item.h"
14 #include "chrome/installer/util/delete_reg_key_work_item.h" 15 #include "chrome/installer/util/delete_reg_key_work_item.h"
15 #include "chrome/installer/util/delete_reg_value_work_item.h" 16 #include "chrome/installer/util/delete_reg_value_work_item.h"
16 #include "chrome/installer/util/delete_tree_work_item.h" 17 #include "chrome/installer/util/delete_tree_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 #include "chrome/installer/util/work_item_list.h" 21 #include "chrome/installer/util/work_item_list.h"
21 22
22 WorkItem::WorkItem() : ignore_failure_(false) { 23 WorkItem::WorkItem() = default;
23 } 24 WorkItem::~WorkItem() = default;
24
25 WorkItem::~WorkItem() {
26 }
27 25
28 CallbackWorkItem* WorkItem::CreateCallbackWorkItem( 26 CallbackWorkItem* WorkItem::CreateCallbackWorkItem(
29 base::Callback<bool(const CallbackWorkItem&)> callback) { 27 base::Callback<bool(const CallbackWorkItem&)> callback) {
30 return new CallbackWorkItem(callback); 28 return new CallbackWorkItem(callback);
31 } 29 }
32 30
33 CopyTreeWorkItem* WorkItem::CreateCopyTreeWorkItem( 31 CopyTreeWorkItem* WorkItem::CreateCopyTreeWorkItem(
34 const base::FilePath& source_path, 32 const base::FilePath& source_path,
35 const base::FilePath& dest_path, 33 const base::FilePath& dest_path,
36 const base::FilePath& temp_dir, 34 const base::FilePath& temp_dir,
(...skipping 26 matching lines...) Expand all
63 HKEY predefined_root, 61 HKEY predefined_root,
64 const std::wstring& key_path, 62 const std::wstring& key_path,
65 REGSAM wow64_access, 63 REGSAM wow64_access,
66 const std::wstring& value_name) { 64 const std::wstring& value_name) {
67 return new DeleteRegValueWorkItem( 65 return new DeleteRegValueWorkItem(
68 predefined_root, key_path, wow64_access, value_name); 66 predefined_root, key_path, wow64_access, value_name);
69 } 67 }
70 68
71 DeleteTreeWorkItem* WorkItem::CreateDeleteTreeWorkItem( 69 DeleteTreeWorkItem* WorkItem::CreateDeleteTreeWorkItem(
72 const base::FilePath& root_path, 70 const base::FilePath& root_path,
73 const base::FilePath& temp_path, 71 const base::FilePath& temp_path) {
74 const std::vector<base::FilePath>& key_paths) { 72 return new DeleteTreeWorkItem(root_path, temp_path);
75 return new DeleteTreeWorkItem(root_path, temp_path, key_paths);
76 } 73 }
77 74
78 MoveTreeWorkItem* WorkItem::CreateMoveTreeWorkItem( 75 MoveTreeWorkItem* WorkItem::CreateMoveTreeWorkItem(
79 const base::FilePath& source_path, 76 const base::FilePath& source_path,
80 const base::FilePath& dest_path, 77 const base::FilePath& dest_path,
81 const base::FilePath& temp_dir, 78 const base::FilePath& temp_dir,
82 MoveTreeOption duplicate_option) { 79 MoveTreeOption duplicate_option) {
83 return new MoveTreeWorkItem(source_path, 80 return new MoveTreeWorkItem(source_path,
84 dest_path, 81 dest_path,
85 temp_dir, 82 temp_dir,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 SelfRegWorkItem* WorkItem::CreateSelfRegWorkItem(const std::wstring& dll_path, 144 SelfRegWorkItem* WorkItem::CreateSelfRegWorkItem(const std::wstring& dll_path,
148 bool do_register, 145 bool do_register,
149 bool user_level_registration) { 146 bool user_level_registration) {
150 return new SelfRegWorkItem(dll_path, do_register, user_level_registration); 147 return new SelfRegWorkItem(dll_path, do_register, user_level_registration);
151 } 148 }
152 149
153 WorkItemList* WorkItem::CreateWorkItemList() { 150 WorkItemList* WorkItem::CreateWorkItemList() {
154 return new WorkItemList(); 151 return new WorkItemList();
155 } 152 }
156 153
157 // static
158 WorkItemList* WorkItem::CreateNoRollbackWorkItemList() {
159 return new NoRollbackWorkItemList();
160 }
161
162 WorkItemList* WorkItem::CreateConditionalWorkItemList(Condition* condition) { 154 WorkItemList* WorkItem::CreateConditionalWorkItemList(Condition* condition) {
163 return new ConditionalWorkItemList(condition); 155 return new ConditionalWorkItemList(condition);
164 } 156 }
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698