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/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/installer/util/callback_work_item.h" | 9 #include "chrome/installer/util/callback_work_item.h" |
10 #include "chrome/installer/util/copy_tree_work_item.h" | 10 #include "chrome/installer/util/copy_tree_work_item.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 for (WorkItemIterator itr = executed_list_.begin(); | 25 for (WorkItemIterator itr = executed_list_.begin(); |
26 itr != executed_list_.end(); ++itr) { | 26 itr != executed_list_.end(); ++itr) { |
27 delete (*itr); | 27 delete (*itr); |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 WorkItemList::WorkItemList() | 31 WorkItemList::WorkItemList() |
32 : status_(ADD_ITEM) { | 32 : status_(ADD_ITEM) { |
33 } | 33 } |
34 | 34 |
35 bool WorkItemList::Do() { | 35 bool WorkItemList::DoImpl() { |
36 if (status_ != ADD_ITEM) | 36 DCHECK_EQ(ADD_ITEM, status_); |
37 return false; | |
38 | 37 |
39 bool result = true; | 38 bool result = true; |
40 while (!list_.empty()) { | 39 while (!list_.empty()) { |
41 WorkItem* work_item = list_.front(); | 40 WorkItem* work_item = list_.front(); |
42 list_.pop_front(); | 41 list_.pop_front(); |
43 executed_list_.push_front(work_item); | 42 executed_list_.push_front(work_item); |
44 if (!work_item->Do()) { | 43 if (!work_item->Do()) { |
45 LOG(ERROR) << "item execution failed " << work_item->log_message(); | 44 LOG(ERROR) << "item execution failed " << work_item->log_message(); |
46 result = false; | 45 result = false; |
47 break; | 46 break; |
48 } | 47 } |
49 } | 48 } |
50 | 49 |
51 if (result) | 50 if (result) |
52 VLOG(1) << "list execution succeeded"; | 51 VLOG(1) << "list execution succeeded"; |
53 | 52 |
54 status_ = LIST_EXECUTED; | 53 status_ = LIST_EXECUTED; |
55 return result; | 54 return result; |
56 } | 55 } |
57 | 56 |
58 void WorkItemList::Rollback() { | 57 void WorkItemList::RollbackImpl() { |
59 if (status_ != LIST_EXECUTED) | 58 if (status_ != LIST_EXECUTED) |
60 return; | 59 return; |
61 | 60 |
62 for (WorkItemIterator itr = executed_list_.begin(); | 61 for (WorkItemIterator itr = executed_list_.begin(); |
63 itr != executed_list_.end(); ++itr) { | 62 itr != executed_list_.end(); ++itr) { |
64 (*itr)->Rollback(); | 63 (*itr)->Rollback(); |
65 } | 64 } |
66 | 65 |
67 status_ = LIST_ROLLED_BACK; | 66 status_ = LIST_ROLLED_BACK; |
68 return; | 67 return; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 WorkItem* item = WorkItem::CreateSelfRegWorkItem(dll_path, do_register, | 228 WorkItem* item = WorkItem::CreateSelfRegWorkItem(dll_path, do_register, |
230 user_level_registration); | 229 user_level_registration); |
231 AddWorkItem(item); | 230 AddWorkItem(item); |
232 return item; | 231 return item; |
233 } | 232 } |
234 | 233 |
235 //////////////////////////////////////////////////////////////////////////////// | 234 //////////////////////////////////////////////////////////////////////////////// |
236 NoRollbackWorkItemList::~NoRollbackWorkItemList() { | 235 NoRollbackWorkItemList::~NoRollbackWorkItemList() { |
237 } | 236 } |
238 | 237 |
239 bool NoRollbackWorkItemList::Do() { | 238 bool NoRollbackWorkItemList::DoImpl() { |
grt (UTC plus 2)
2016/04/27 17:29:17
do we need this class? can WIL::DoImpl check its o
fdoray
2016/05/02 20:10:00
Applying the WIL's allow_rollback/best_effort flag
grt (UTC plus 2)
2016/05/06 18:39:13
No. It'd be nice to have something like:
VLOG(1
| |
240 if (status_ != ADD_ITEM) | 239 DCHECK_EQ(ADD_ITEM, status_); |
241 return false; | |
242 | 240 |
243 bool result = true; | 241 bool result = true; |
244 while (!list_.empty()) { | 242 while (!list_.empty()) { |
245 WorkItem* work_item = list_.front(); | 243 WorkItem* work_item = list_.front(); |
246 list_.pop_front(); | 244 list_.pop_front(); |
247 executed_list_.push_front(work_item); | 245 executed_list_.push_front(work_item); |
248 work_item->set_ignore_failure(true); | 246 work_item->set_allow_rollback(false); |
249 if (!work_item->Do()) { | 247 if (!work_item->Do()) { |
250 LOG(ERROR) << "NoRollbackWorkItemList: item execution failed " | 248 LOG(ERROR) << "NoRollbackWorkItemList: item execution failed " |
251 << work_item->log_message(); | 249 << work_item->log_message(); |
252 result = false; | 250 result = false; |
253 } | 251 } |
254 } | 252 } |
255 | 253 |
256 if (result) | 254 if (result) |
257 VLOG(1) << "NoRollbackWorkItemList: list execution succeeded"; | 255 VLOG(1) << "NoRollbackWorkItemList: list execution succeeded"; |
258 | 256 |
259 status_ = LIST_EXECUTED; | 257 status_ = LIST_EXECUTED; |
260 return result; | 258 return result; |
261 } | 259 } |
262 | 260 |
263 void NoRollbackWorkItemList::Rollback() { | 261 void NoRollbackWorkItemList::RollbackImpl() { |
264 // Ignore rollback. | 262 // Ignore rollback. |
265 } | 263 } |
OLD | NEW |