| 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 // Base class for managing an action of a sequence of actions to be carried | 5 // Base class for managing an action of a sequence of actions to be carried |
| 6 // out during install/update/uninstall. Supports rollback of actions if this | 6 // out during install/update/uninstall. Supports rollback of actions if this |
| 7 // process fails. | 7 // process fails. |
| 8 | 8 |
| 9 #ifndef CHROME_INSTALLER_UTIL_WORK_ITEM_H_ | 9 #ifndef CHROME_INSTALLER_UTIL_WORK_ITEM_H_ |
| 10 #define CHROME_INSTALLER_UTIL_WORK_ITEM_H_ | 10 #define CHROME_INSTALLER_UTIL_WORK_ITEM_H_ |
| 11 | 11 |
| 12 #include <windows.h> | 12 #include <windows.h> |
| 13 | 13 |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/callback.h" |
| 18 | 19 |
| 20 class CallbackWorkItem; |
| 19 class CopyRegKeyWorkItem; | 21 class CopyRegKeyWorkItem; |
| 20 class CopyTreeWorkItem; | 22 class CopyTreeWorkItem; |
| 21 class CreateDirWorkItem; | 23 class CreateDirWorkItem; |
| 22 class CreateRegKeyWorkItem; | 24 class CreateRegKeyWorkItem; |
| 23 class DeleteTreeWorkItem; | 25 class DeleteTreeWorkItem; |
| 24 class DeleteRegKeyWorkItem; | 26 class DeleteRegKeyWorkItem; |
| 25 class DeleteRegValueWorkItem; | 27 class DeleteRegValueWorkItem; |
| 26 class FilePath; | 28 class FilePath; |
| 27 class MoveTreeWorkItem; | 29 class MoveTreeWorkItem; |
| 28 class SelfRegWorkItem; | 30 class SelfRegWorkItem; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 51 // Abstract base class for the conditions used by ConditionWorkItemList. | 53 // Abstract base class for the conditions used by ConditionWorkItemList. |
| 52 // TODO(robertshield): Move this out of WorkItem. | 54 // TODO(robertshield): Move this out of WorkItem. |
| 53 class Condition { | 55 class Condition { |
| 54 public: | 56 public: |
| 55 virtual ~Condition() {} | 57 virtual ~Condition() {} |
| 56 virtual bool ShouldRun() const = 0; | 58 virtual bool ShouldRun() const = 0; |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 virtual ~WorkItem(); | 61 virtual ~WorkItem(); |
| 60 | 62 |
| 63 // Create a CallbackWorkItem that invokes a callback. |
| 64 static CallbackWorkItem* CreateCallbackWorkItem( |
| 65 base::Callback<bool(const CallbackWorkItem&)> callback); |
| 66 |
| 61 // Create a CopyRegKeyWorkItem that recursively copies a given registry key. | 67 // Create a CopyRegKeyWorkItem that recursively copies a given registry key. |
| 62 static CopyRegKeyWorkItem* CreateCopyRegKeyWorkItem( | 68 static CopyRegKeyWorkItem* CreateCopyRegKeyWorkItem( |
| 63 HKEY predefined_root, | 69 HKEY predefined_root, |
| 64 const std::wstring& source_key_path, | 70 const std::wstring& source_key_path, |
| 65 const std::wstring& dest_key_path, | 71 const std::wstring& dest_key_path, |
| 66 CopyOverWriteOption overwrite_option); | 72 CopyOverWriteOption overwrite_option); |
| 67 | 73 |
| 68 // Create a CopyTreeWorkItem that recursively copies a file system hierarchy | 74 // Create a CopyTreeWorkItem that recursively copies a file system hierarchy |
| 69 // from source path to destination path. | 75 // from source path to destination path. |
| 70 // * If overwrite_option is ALWAYS, the created CopyTreeWorkItem always | 76 // * If overwrite_option is ALWAYS, the created CopyTreeWorkItem always |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // rolled back. If the WorkItem is non-transactional, the rollback is a | 175 // rolled back. If the WorkItem is non-transactional, the rollback is a |
| 170 // best effort. | 176 // best effort. |
| 171 virtual void Rollback() = 0; | 177 virtual void Rollback() = 0; |
| 172 | 178 |
| 173 // If called with true, this WorkItem may return true from its Do() method | 179 // If called with true, this WorkItem may return true from its Do() method |
| 174 // even on failure and Rollback will have no effect. | 180 // even on failure and Rollback will have no effect. |
| 175 void set_ignore_failure(bool ignore_failure) { | 181 void set_ignore_failure(bool ignore_failure) { |
| 176 ignore_failure_ = ignore_failure; | 182 ignore_failure_ = ignore_failure; |
| 177 } | 183 } |
| 178 | 184 |
| 185 // Returns true if this WorkItem should ignore failures. |
| 186 bool ignore_failure() const { |
| 187 return ignore_failure_; |
| 188 } |
| 189 |
| 179 // Sets an optional log message that a work item may use to print additional | 190 // Sets an optional log message that a work item may use to print additional |
| 180 // instance-specific information. | 191 // instance-specific information. |
| 181 void set_log_message(const std::string& log_message) { | 192 void set_log_message(const std::string& log_message) { |
| 182 log_message_ = log_message; | 193 log_message_ = log_message; |
| 183 } | 194 } |
| 184 | 195 |
| 185 // Retrieves the optional log message. The retrieved string may be empty. | 196 // Retrieves the optional log message. The retrieved string may be empty. |
| 186 std::string log_message() { return log_message_; } | 197 const std::string& log_message() const { return log_message_; } |
| 187 | 198 |
| 188 protected: | 199 protected: |
| 189 WorkItem(); | 200 WorkItem(); |
| 190 | 201 |
| 191 // Specifies whether this work item my fail to complete and yet still | 202 // Specifies whether this work item my fail to complete and yet still |
| 192 // return true from Do(). | 203 // return true from Do(). |
| 193 bool ignore_failure_; | 204 bool ignore_failure_; |
| 194 | 205 |
| 195 std::string log_message_; | 206 std::string log_message_; |
| 196 }; | 207 }; |
| 197 | 208 |
| 198 #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_H_ | 209 #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_H_ |
| OLD | NEW |