Index: chrome/installer/util/delete_tree_work_item.h |
=================================================================== |
--- chrome/installer/util/delete_tree_work_item.h (revision 75264) |
+++ chrome/installer/util/delete_tree_work_item.h (working copy) |
@@ -6,20 +6,18 @@ |
#define CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ |
#pragma once |
-#include <windows.h> |
- |
-#include <string> |
-#include <utility> |
#include <vector> |
#include "base/file_path.h" |
+#include "base/scoped_ptr.h" |
+#include "base/scoped_temp_dir.h" |
#include "chrome/installer/util/work_item.h" |
// A WorkItem subclass that recursively deletes a file system hierarchy at the |
// given root path. The file system hierarchy could be a single file, or a |
// directory. |
-// The file system hierarchy to be deleted can have a key file. If the key file |
-// is specified, deletion will be performed only if the key file is not in use. |
+// The file system hierarchy to be deleted can have one or more key files. If |
+// specified, deletion will be performed only if all key files are not in use. |
class DeleteTreeWorkItem : public WorkItem { |
public: |
virtual ~DeleteTreeWorkItem(); |
@@ -31,28 +29,30 @@ |
private: |
friend class WorkItem; |
- // A list of key file paths and paths to a backup of a key file. |
- // the 'first' member of the pair has the key file path, the 'second' has |
- // the path to the backup. |
- typedef std::vector<std::pair<FilePath, FilePath> > KeyFileList; |
- |
- // Get a backup path that can keep root_path_ or key_paths_ |
- bool GetBackupPath(const FilePath& for_path, FilePath* backup_path); |
- |
DeleteTreeWorkItem(const FilePath& root_path, |
+ const FilePath& temp_path, |
const std::vector<FilePath>& key_paths); |
// Root path to delete. |
FilePath root_path_; |
- // Contains the path to key files and their backups once Do() has been called. |
- // If key files are specified, deletion will be performed only if none of the |
- // key files are in use. |
- KeyFileList key_paths_; |
+ // Temporary directory that can be used. |
+ FilePath temp_path_; |
- // The full path in temporary directory that the original root_path_ has |
- // been moved to. |
- FilePath backup_path_; |
+ // The number of key files. |
+ ptrdiff_t num_key_files_; |
+ |
+ // Contains the paths to the key files. If specified, deletion will be |
+ // performed only if none of the key files are in use. |
+ scoped_array<FilePath> key_paths_; |
+ |
+ // Contains the temp directories for the backed-up key files. The directories |
+ // are created and populated in Do() as-needed. We don't use a standard |
+ // container for this since ScopedTempDir isn't CopyConstructible. |
+ scoped_array<ScopedTempDir> key_backup_paths_; |
+ |
+ // The temporary directory into which the original root_path_ has been moved. |
+ ScopedTempDir backup_path_; |
}; |
#endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ |