OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_DELETE_TREE_WORK_ITEM_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ |
6 #define CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ | 6 #define CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <utility> | |
13 #include <vector> | |
12 | 14 |
13 #include "base/file_path.h" | 15 #include "base/file_path.h" |
14 #include "chrome/installer/util/work_item.h" | 16 #include "chrome/installer/util/work_item.h" |
15 | 17 |
16 // A WorkItem subclass that recursively deletes a file system hierarchy at the | 18 // A WorkItem subclass that recursively deletes a file system hierarchy at the |
17 // given root path. The file system hierarchy could be a single file, or a | 19 // given root path. The file system hierarchy could be a single file, or a |
18 // directory. | 20 // directory. |
19 // The file system hierarchy to be deleted can have a key file. If the key file | 21 // The file system hierarchy to be deleted can have a key file. If the key file |
20 // is specified, deletion will be performed only if the key file is not in use. | 22 // is specified, deletion will be performed only if the key file is not in use. |
21 class DeleteTreeWorkItem : public WorkItem { | 23 class DeleteTreeWorkItem : public WorkItem { |
22 public: | 24 public: |
23 virtual ~DeleteTreeWorkItem(); | 25 virtual ~DeleteTreeWorkItem(); |
24 | 26 |
25 virtual bool Do(); | 27 virtual bool Do(); |
26 | 28 |
27 virtual void Rollback(); | 29 virtual void Rollback(); |
28 | 30 |
29 private: | 31 private: |
30 friend class WorkItem; | 32 friend class WorkItem; |
31 | 33 |
32 // Get a backup path that can keep root_path_ or key_path_ | 34 // A list of key file paths and paths to a backup of a key file. |
35 // the 'first' member of the pair has the key file path, the 'second' has | |
36 // the path to the backup. | |
37 typedef std::vector<std::pair<FilePath, FilePath> > KeyFileList; | |
38 | |
39 // Get a backup path that can keep root_path_ or key_paths_ | |
33 bool GetBackupPath(const FilePath& for_path, FilePath* backup_path); | 40 bool GetBackupPath(const FilePath& for_path, FilePath* backup_path); |
34 | 41 |
35 DeleteTreeWorkItem(const std::wstring& root_path, | 42 DeleteTreeWorkItem(const FilePath& root_path, |
36 const std::wstring& key_path); | 43 const std::vector<FilePath>& key_paths); |
37 | 44 |
38 // Root path to delete. | 45 // Root path to delete. |
39 FilePath root_path_; | 46 FilePath root_path_; |
40 | 47 |
41 // Path to the key file. If the key file is specified, deletion will be | 48 // Contains the path to key files and their backups once the WorkItem has |
42 // performed only if the key file is not in use. | 49 // started working. If key files are specified, deletion will be performed |
robertshield
2010/12/01 21:40:54
"the WorkItem has started working" -> "Do() has be
tommi (sloooow) - chröme
2010/12/01 22:07:15
Done.
| |
43 FilePath key_path_; | 50 // only if none of the key files are in use. |
51 KeyFileList key_paths_; | |
44 | 52 |
45 // The full path in temporary directory that the original root_path_ has | 53 // The full path in temporary directory that the original root_path_ has |
46 // been moved to. | 54 // been moved to. |
47 FilePath backup_path_; | 55 FilePath backup_path_; |
48 | |
49 // The full path in temporary directory that the original key_path_ has | |
50 // been moved to. | |
51 FilePath key_backup_path_; | |
52 }; | 56 }; |
53 | 57 |
54 #endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ | 58 #endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ |
OLD | NEW |