Index: chrome/installer/util/work_item_list.cc |
diff --git a/chrome/installer/util/work_item_list.cc b/chrome/installer/util/work_item_list.cc |
index 609933065afaa65ac768c1c48a34d0820e2b79ef..20210276495c5550a590dcab74d251e312cb3979 100644 |
--- a/chrome/installer/util/work_item_list.cc |
+++ b/chrome/installer/util/work_item_list.cc |
@@ -28,19 +28,16 @@ WorkItemList::~WorkItemList() { |
} |
} |
-WorkItemList::WorkItemList() |
- : status_(ADD_ITEM) { |
-} |
- |
-bool WorkItemList::Do() { |
- if (status_ != ADD_ITEM) |
- return false; |
+WorkItemList::WorkItemList() = default; |
+bool WorkItemList::DoImpl() { |
bool result = true; |
while (!list_.empty()) { |
WorkItem* work_item = list_.front(); |
list_.pop_front(); |
executed_list_.push_front(work_item); |
+ work_item->set_best_effort(best_effort()); |
grt (UTC plus 2)
2016/05/06 18:39:13
hmm. one flaw with this is that you can't add a be
fdoray
2016/05/10 18:35:32
Now I only make the work items best-effort if the
|
+ work_item->set_rollback_enabled(rollback_enabled()); |
if (!work_item->Do()) { |
LOG(ERROR) << "item execution failed " << work_item->log_message(); |
result = false; |
@@ -51,25 +48,18 @@ bool WorkItemList::Do() { |
if (result) |
VLOG(1) << "list execution succeeded"; |
- status_ = LIST_EXECUTED; |
return result; |
} |
-void WorkItemList::Rollback() { |
- if (status_ != LIST_EXECUTED) |
- return; |
- |
+void WorkItemList::RollbackImpl() { |
for (WorkItemIterator itr = executed_list_.begin(); |
itr != executed_list_.end(); ++itr) { |
(*itr)->Rollback(); |
} |
- |
- status_ = LIST_ROLLED_BACK; |
- return; |
} |
void WorkItemList::AddWorkItem(WorkItem* work_item) { |
- DCHECK(status_ == ADD_ITEM); |
+ DCHECK_EQ(WorkItem::BEFORE_DO, state()); |
grt (UTC plus 2)
2016/05/06 18:39:13
nit: no need for WorkItem:: here
fdoray
2016/05/10 18:35:31
Done.
|
list_.push_back(work_item); |
} |
@@ -236,16 +226,13 @@ WorkItem* WorkItemList::AddSelfRegWorkItem(const std::wstring& dll_path, |
NoRollbackWorkItemList::~NoRollbackWorkItemList() { |
} |
-bool NoRollbackWorkItemList::Do() { |
- if (status_ != ADD_ITEM) |
- return false; |
- |
+bool NoRollbackWorkItemList::DoImpl() { |
bool result = true; |
while (!list_.empty()) { |
WorkItem* work_item = list_.front(); |
list_.pop_front(); |
executed_list_.push_front(work_item); |
- work_item->set_ignore_failure(true); |
+ work_item->set_rollback_enabled(false); |
if (!work_item->Do()) { |
LOG(ERROR) << "NoRollbackWorkItemList: item execution failed " |
<< work_item->log_message(); |
@@ -256,10 +243,9 @@ bool NoRollbackWorkItemList::Do() { |
if (result) |
VLOG(1) << "NoRollbackWorkItemList: list execution succeeded"; |
- status_ = LIST_EXECUTED; |
return result; |
} |
-void NoRollbackWorkItemList::Rollback() { |
+void NoRollbackWorkItemList::RollbackImpl() { |
// Ignore rollback. |
} |