OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/conditional_work_item_list.h" | 5 #include "chrome/installer/util/conditional_work_item_list.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 ConditionalWorkItemList::ConditionalWorkItemList(Condition* condition) | 10 ConditionalWorkItemList::ConditionalWorkItemList(Condition* condition) |
11 : condition_(condition) { | 11 : condition_(condition) { |
12 } | 12 } |
13 | 13 |
14 ConditionalWorkItemList::~ConditionalWorkItemList() {} | 14 ConditionalWorkItemList::~ConditionalWorkItemList() {} |
15 | 15 |
16 bool ConditionalWorkItemList::DoImpl() { | 16 bool ConditionalWorkItemList::Do() { |
17 VLOG(1) << "Evaluating " << log_message_ << " condition..."; | 17 VLOG(1) << "Evaluating " << log_message_ << " condition..."; |
18 if (condition_.get() && condition_->ShouldRun()) { | 18 if (condition_.get() && condition_->ShouldRun()) { |
19 VLOG(1) << "Beginning conditional work item list"; | 19 VLOG(1) << "Beginning conditional work item list"; |
20 return WorkItemList::DoImpl(); | 20 return WorkItemList::Do(); |
21 } | 21 } |
22 VLOG(1) << "No work to do in condition work item list " | 22 VLOG(1) << "No work to do in condition work item list " |
23 << log_message_; | 23 << log_message_; |
24 return true; | 24 return true; |
25 } | 25 } |
26 | 26 |
27 void ConditionalWorkItemList::RollbackImpl() { | 27 void ConditionalWorkItemList::Rollback() { |
28 VLOG(1) << "Rolling back conditional list " << log_message_; | 28 VLOG(1) << "Rolling back conditional list " << log_message_; |
29 WorkItemList::RollbackImpl(); | 29 WorkItemList::Rollback(); |
30 } | 30 } |
31 | 31 |
32 // Pre-defined conditions: | 32 // Pre-defined conditions: |
33 //------------------------------------------------------------------------------ | 33 //------------------------------------------------------------------------------ |
34 bool ConditionRunIfFileExists::ShouldRun() const { | 34 bool ConditionRunIfFileExists::ShouldRun() const { |
35 return base::PathExists(key_path_); | 35 return base::PathExists(key_path_); |
36 } | 36 } |
37 | 37 |
38 Not::Not(WorkItem::Condition* original_condition) | 38 Not::Not(WorkItem::Condition* original_condition) |
39 : original_condition_(original_condition) { | 39 : original_condition_(original_condition) { |
40 } | 40 } |
41 | 41 |
42 Not::~Not() { | 42 Not::~Not() { |
43 } | 43 } |
44 | 44 |
45 bool Not::ShouldRun() const { | 45 bool Not::ShouldRun() const { |
46 return !original_condition_->ShouldRun(); | 46 return !original_condition_->ShouldRun(); |
47 } | 47 } |
OLD | NEW |