| 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_WORK_ITEM_LIST_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ |
| 6 #define CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ | 6 #define CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback_forward.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "chrome/installer/util/work_item.h" | 16 #include "chrome/installer/util/work_item.h" |
| 16 | 17 |
| 17 class FilePath; | 18 class FilePath; |
| 18 | 19 |
| 19 // A WorkItem subclass that recursively contains a list of WorkItems. Thus it | 20 // A WorkItem subclass that recursively contains a list of WorkItems. Thus it |
| 20 // provides functionalities to carry out or roll back the sequence of actions | 21 // provides functionalities to carry out or roll back the sequence of actions |
| 21 // defined by the list of WorkItems it contains. | 22 // defined by the list of WorkItems it contains. |
| 22 // The WorkItems are executed in the same order as they are added to the list. | 23 // The WorkItems are executed in the same order as they are added to the list. |
| 23 class WorkItemList : public WorkItem { | 24 class WorkItemList : public WorkItem { |
| 24 public: | 25 public: |
| 25 virtual ~WorkItemList(); | 26 virtual ~WorkItemList(); |
| 26 | 27 |
| 27 // Execute the WorkItems in the same order as they are added to the list. | 28 // Execute the WorkItems in the same order as they are added to the list. |
| 28 // It aborts as soon as one WorkItem fails. | 29 // It aborts as soon as one WorkItem fails. |
| 29 virtual bool Do(); | 30 virtual bool Do(); |
| 30 | 31 |
| 31 // Rollback the WorkItems in the reverse order as they are executed. | 32 // Rollback the WorkItems in the reverse order as they are executed. |
| 32 virtual void Rollback(); | 33 virtual void Rollback(); |
| 33 | 34 |
| 34 // Add a WorkItem to the list. | 35 // Add a WorkItem to the list. |
| 35 // A WorkItem can only be added to the list before the list's DO() is called. | 36 // A WorkItem can only be added to the list before the list's DO() is called. |
| 36 // Once a WorkItem is added to the list. The list owns the WorkItem. | 37 // Once a WorkItem is added to the list. The list owns the WorkItem. |
| 37 virtual void AddWorkItem(WorkItem* work_item); | 38 virtual void AddWorkItem(WorkItem* work_item); |
| 38 | 39 |
| 40 // Add a CallbackWorkItem that invokes a callback. |
| 41 virtual WorkItem* AddCallbackWorkItem( |
| 42 base::Callback<bool(const CallbackWorkItem&)> callback); |
| 43 |
| 39 // Add a CopyRegKeyWorkItem that recursively copies a given registry key. | 44 // Add a CopyRegKeyWorkItem that recursively copies a given registry key. |
| 40 virtual WorkItem* AddCopyRegKeyWorkItem(HKEY predefined_root, | 45 virtual WorkItem* AddCopyRegKeyWorkItem(HKEY predefined_root, |
| 41 const std::wstring& source_key_path, | 46 const std::wstring& source_key_path, |
| 42 const std::wstring& dest_key_path, | 47 const std::wstring& dest_key_path, |
| 43 CopyOverWriteOption overwrite_option); | 48 CopyOverWriteOption overwrite_option); |
| 44 | 49 |
| 45 // Add a CopyTreeWorkItem to the list of work items. | 50 // Add a CopyTreeWorkItem to the list of work items. |
| 46 // See the NOTE in the documentation for the CopyTreeWorkItem class for | 51 // See the NOTE in the documentation for the CopyTreeWorkItem class for |
| 47 // special considerations regarding |temp_dir|. | 52 // special considerations regarding |temp_dir|. |
| 48 virtual WorkItem* AddCopyTreeWorkItem( | 53 virtual WorkItem* AddCopyTreeWorkItem( |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // Execute the WorkItems in the same order as they are added to the list. | 163 // Execute the WorkItems in the same order as they are added to the list. |
| 159 // If a WorkItem fails, the function will return failure but all other | 164 // If a WorkItem fails, the function will return failure but all other |
| 160 // WorkItems will still be executed. | 165 // WorkItems will still be executed. |
| 161 virtual bool Do(); | 166 virtual bool Do(); |
| 162 | 167 |
| 163 // Just does a NOTREACHED. | 168 // Just does a NOTREACHED. |
| 164 virtual void Rollback(); | 169 virtual void Rollback(); |
| 165 }; | 170 }; |
| 166 | 171 |
| 167 #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ | 172 #endif // CHROME_INSTALLER_UTIL_WORK_ITEM_LIST_H_ |
| OLD | NEW |