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 #ifndef CHROME_INSTALLER_UTIL_CONDITIONAL_WORK_ITEM_LIST_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_CONDITIONAL_WORK_ITEM_LIST_H_ |
6 #define CHROME_INSTALLER_UTIL_CONDITIONAL_WORK_ITEM_LIST_H_ | 6 #define CHROME_INSTALLER_UTIL_CONDITIONAL_WORK_ITEM_LIST_H_ |
7 | 7 |
8 #include "chrome/installer/util/work_item_list.h" | 8 #include "chrome/installer/util/work_item_list.h" |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 | 12 |
13 // A WorkItemList subclass that permits conditionally executing a set of | 13 // A WorkItemList subclass that permits conditionally executing a set of |
14 // WorkItems. | 14 // WorkItems. |
15 class ConditionalWorkItemList : public WorkItemList { | 15 class ConditionalWorkItemList : public WorkItemList { |
16 public: | 16 public: |
17 explicit ConditionalWorkItemList(Condition* condition); | 17 explicit ConditionalWorkItemList(Condition* condition); |
18 ~ConditionalWorkItemList() override; | 18 ~ConditionalWorkItemList() override; |
19 | 19 |
20 private: | |
21 // WorkItemList: | |
22 | |
20 // If condition_->ShouldRun() returns true, then execute the items in this | 23 // If condition_->ShouldRun() returns true, then execute the items in this |
21 // list and return true iff they all succeed. If condition_->ShouldRun() | 24 // list and return true iff they all succeed. If condition_->ShouldRun() |
22 // returns false, does nothing and returns true. | 25 // returns false, does nothing and returns true. |
23 bool Do() override; | 26 bool DoImpl() override; |
24 | 27 |
25 // Does a rollback of the items (if any) that were run in Do. | 28 // Does a rollback of the items (if any) that were run in Do. |
26 void Rollback() override; | 29 void RollbackImpl() override; |
27 | 30 |
28 protected: | |
29 // Pointer to a Condition that is used to determine whether to run this | 31 // Pointer to a Condition that is used to determine whether to run this |
30 // WorkItemList. | 32 // WorkItemList. |
31 scoped_ptr<Condition> condition_; | 33 scoped_ptr<Condition> condition_; |
grt (UTC plus 2)
2016/04/27 17:29:16
std::unique_ptr
fdoray
2016/05/02 20:10:00
Rebase took care of this.
| |
32 }; | 34 }; |
33 | 35 |
34 | 36 |
35 // Pre-defined conditions: | 37 // Pre-defined conditions: |
36 //------------------------------------------------------------------------------ | 38 //------------------------------------------------------------------------------ |
37 class ConditionRunIfFileExists : public WorkItem::Condition { | 39 class ConditionRunIfFileExists : public WorkItem::Condition { |
38 public: | 40 public: |
39 explicit ConditionRunIfFileExists(const base::FilePath& key_path) | 41 explicit ConditionRunIfFileExists(const base::FilePath& key_path) |
40 : key_path_(key_path) {} | 42 : key_path_(key_path) {} |
41 bool ShouldRun() const override; | 43 bool ShouldRun() const override; |
42 | 44 |
43 private: | 45 private: |
44 base::FilePath key_path_; | 46 base::FilePath key_path_; |
45 }; | 47 }; |
46 | 48 |
47 // Condition class that inverts the ShouldRun result of another Condition. | 49 // Condition class that inverts the ShouldRun result of another Condition. |
48 // This class assumes ownership of original_condition. | 50 // This class assumes ownership of original_condition. |
49 class Not : public WorkItem::Condition { | 51 class Not : public WorkItem::Condition { |
50 public: | 52 public: |
51 explicit Not(WorkItem::Condition* original_condition); | 53 explicit Not(WorkItem::Condition* original_condition); |
52 ~Not() override; | 54 ~Not() override; |
53 | 55 |
54 bool ShouldRun() const override; | 56 bool ShouldRun() const override; |
55 | 57 |
56 private: | 58 private: |
57 scoped_ptr<WorkItem::Condition> original_condition_; | 59 scoped_ptr<WorkItem::Condition> original_condition_; |
58 }; | 60 }; |
59 | 61 |
60 #endif // CHROME_INSTALLER_UTIL_CONDITIONAL_WORK_ITEM_LIST_H_ | 62 #endif // CHROME_INSTALLER_UTIL_CONDITIONAL_WORK_ITEM_LIST_H_ |
OLD | NEW |