Roll src/third_party/WebKit 116cf7f:79abaa8 (svn 189234:189235)
[chromium-blink-merge.git] / chrome / installer / util / conditional_work_item_list.cc
blobad669448a18bd93f6ee96b972caefce60419f775
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
3 // found in the LICENSE file.
5 #include "chrome/installer/util/conditional_work_item_list.h"
7 #include "base/files/file_util.h"
8 #include "base/logging.h"
10 ConditionalWorkItemList::ConditionalWorkItemList(Condition* condition)
11 : condition_(condition) {
14 ConditionalWorkItemList::~ConditionalWorkItemList() {}
16 bool ConditionalWorkItemList::Do() {
17 VLOG(1) << "Evaluating " << log_message_ << " condition...";
18 if (condition_.get() && condition_->ShouldRun()) {
19 VLOG(1) << "Beginning conditional work item list";
20 return WorkItemList::Do();
22 VLOG(1) << "No work to do in condition work item list "
23 << log_message_;
24 return true;
27 void ConditionalWorkItemList::Rollback() {
28 VLOG(1) << "Rolling back conditional list " << log_message_;
29 WorkItemList::Rollback();
32 // Pre-defined conditions:
33 //------------------------------------------------------------------------------
34 bool ConditionRunIfFileExists::ShouldRun() const {
35 return base::PathExists(key_path_);
38 bool Not::ShouldRun() const {
39 return !original_condition_->ShouldRun();