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

Unified 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: CR grt #7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/util/work_item.cc
diff --git a/chrome/installer/util/work_item.cc b/chrome/installer/util/work_item.cc
index e38413d94ef34df56a274cf864eab751493fbb96..988a4711f516983b8b6fb849d10c7a8f007d01f3 100644
--- a/chrome/installer/util/work_item.cc
+++ b/chrome/installer/util/work_item.cc
@@ -6,6 +6,7 @@
#include <windows.h>
+#include "base/logging.h"
#include "chrome/installer/util/callback_work_item.h"
#include "chrome/installer/util/conditional_work_item_list.h"
#include "chrome/installer/util/copy_tree_work_item.h"
@@ -19,11 +20,8 @@
#include "chrome/installer/util/set_reg_value_work_item.h"
#include "chrome/installer/util/work_item_list.h"
-WorkItem::WorkItem() : ignore_failure_(false) {
-}
-
-WorkItem::~WorkItem() {
-}
+WorkItem::WorkItem() = default;
+WorkItem::~WorkItem() = default;
CallbackWorkItem* WorkItem::CreateCallbackWorkItem(
base::Callback<bool(const CallbackWorkItem&)> callback) {
@@ -70,9 +68,8 @@ DeleteRegValueWorkItem* WorkItem::CreateDeleteRegValueWorkItem(
DeleteTreeWorkItem* WorkItem::CreateDeleteTreeWorkItem(
const base::FilePath& root_path,
- const base::FilePath& temp_path,
- const std::vector<base::FilePath>& key_paths) {
- return new DeleteTreeWorkItem(root_path, temp_path, key_paths);
+ const base::FilePath& temp_path) {
+ return new DeleteTreeWorkItem(root_path, temp_path);
}
MoveTreeWorkItem* WorkItem::CreateMoveTreeWorkItem(
@@ -154,11 +151,30 @@ WorkItemList* WorkItem::CreateWorkItemList() {
return new WorkItemList();
}
-// static
-WorkItemList* WorkItem::CreateNoRollbackWorkItemList() {
- return new NoRollbackWorkItemList();
-}
-
WorkItemList* WorkItem::CreateConditionalWorkItemList(Condition* condition) {
return new ConditionalWorkItemList(condition);
}
+
+bool WorkItem::Do() {
+ DCHECK_EQ(BEFORE_DO, state_);
+ const bool success = DoImpl();
+ state_ = AFTER_DO;
+ return best_effort() ? true : success;
+}
+
+void WorkItem::Rollback() {
+ DCHECK_EQ(AFTER_DO, state_);
+ if (rollback_enabled())
+ RollbackImpl();
+ state_ = AFTER_ROLLBACK;
+}
+
+void WorkItem::set_best_effort(bool best_effort) {
+ DCHECK_EQ(BEFORE_DO, state());
+ best_effort_ = best_effort;
+}
+
+void WorkItem::set_rollback_enabled(bool rollback_enabled) {
+ DCHECK_EQ(BEFORE_DO, state());
+ rollback_enabled_ = rollback_enabled;
+}

Powered by Google App Engine
This is Rietveld 408576698