Chromium Code Reviews| 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..8c9b6d09ae865c0d102ca20c9aa9d22b885d1e2e 100644 |
| --- a/chrome/installer/util/work_item_list.cc |
| +++ b/chrome/installer/util/work_item_list.cc |
| @@ -28,19 +28,22 @@ WorkItemList::~WorkItemList() { |
| } |
| } |
| -WorkItemList::WorkItemList() |
| - : status_(ADD_ITEM) { |
| -} |
| +WorkItemList::WorkItemList() = default; |
| -bool WorkItemList::Do() { |
| - if (status_ != ADD_ITEM) |
| - return false; |
| +bool WorkItemList::DoImpl() { |
| + VLOG(1) << "Beginning execution of work item list " << log_message(); |
| bool result = true; |
| while (!list_.empty()) { |
| WorkItem* work_item = list_.front(); |
| list_.pop_front(); |
| executed_list_.push_front(work_item); |
| + |
| + if (best_effort()) |
| + work_item->set_best_effort(true); |
| + if (!rollback_enabled()) |
| + work_item->set_rollback_enabled(false); |
| + |
| if (!work_item->Do()) { |
| LOG(ERROR) << "item execution failed " << work_item->log_message(); |
| result = false; |
| @@ -51,25 +54,18 @@ bool WorkItemList::Do() { |
| if (result) |
|
grt (UTC plus 2)
2016/05/12 17:26:24
how about changing this to:
if (result)
VLOG
fdoray
2016/05/13 14:31:45
Done.
|
| 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(BEFORE_DO, state()); |
| list_.push_back(work_item); |
| } |
| @@ -131,20 +127,11 @@ WorkItem* WorkItemList::AddDeleteRegValueWorkItem( |
| return item; |
| } |
| -WorkItem* WorkItemList::AddDeleteTreeWorkItem( |
| - const base::FilePath& root_path, |
| - const base::FilePath& temp_path, |
| - const std::vector<base::FilePath>& key_paths) { |
| - WorkItem* item = WorkItem::CreateDeleteTreeWorkItem(root_path, temp_path, |
| - key_paths); |
| - AddWorkItem(item); |
| - return item; |
| -} |
| - |
| WorkItem* WorkItemList::AddDeleteTreeWorkItem(const base::FilePath& root_path, |
| const base::FilePath& temp_path) { |
| - std::vector<base::FilePath> no_key_files; |
| - return AddDeleteTreeWorkItem(root_path, temp_path, no_key_files); |
| + WorkItem* item = WorkItem::CreateDeleteTreeWorkItem(root_path, temp_path); |
| + AddWorkItem(item); |
| + return item; |
| } |
| WorkItem* WorkItemList::AddMoveTreeWorkItem(const std::wstring& source_path, |
| @@ -231,35 +218,3 @@ WorkItem* WorkItemList::AddSelfRegWorkItem(const std::wstring& dll_path, |
| AddWorkItem(item); |
| return item; |
| } |
| - |
| -//////////////////////////////////////////////////////////////////////////////// |
| -NoRollbackWorkItemList::~NoRollbackWorkItemList() { |
| -} |
| - |
| -bool NoRollbackWorkItemList::Do() { |
| - if (status_ != ADD_ITEM) |
| - return false; |
| - |
| - 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); |
| - if (!work_item->Do()) { |
| - LOG(ERROR) << "NoRollbackWorkItemList: item execution failed " |
| - << work_item->log_message(); |
| - result = false; |
| - } |
| - } |
| - |
| - if (result) |
| - VLOG(1) << "NoRollbackWorkItemList: list execution succeeded"; |
| - |
| - status_ = LIST_EXECUTED; |
| - return result; |
| -} |
| - |
| -void NoRollbackWorkItemList::Rollback() { |
| - // Ignore rollback. |
| -} |