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_COPY_TREE_WORK_ITEM_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ |
6 #define CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ | 6 #define CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <windows.h> | 9 #include <windows.h> |
| 10 |
| 11 #include "base/file_path.h" |
10 #include "chrome/installer/util/work_item.h" | 12 #include "chrome/installer/util/work_item.h" |
11 | 13 |
12 // A WorkItem subclass that recursively copies a file system hierarchy from | 14 // A WorkItem subclass that recursively copies a file system hierarchy from |
13 // source path to destination path. It also creates all necessary intermediate | 15 // source path to destination path. It also creates all necessary intermediate |
14 // paths of the destination path if they do not exist. The file system | 16 // paths of the destination path if they do not exist. The file system |
15 // hierarchy could be a single file, or a directory. | 17 // hierarchy could be a single file, or a directory. |
16 // Under the cover CopyTreeWorkItem moves the destination path, if existing, | 18 // Under the cover CopyTreeWorkItem moves the destination path, if existing, |
17 // to the temporary directory passed in, and then copies the source hierarchy | 19 // to the temporary directory passed in, and then copies the source hierarchy |
18 // to the destination location. During rollback the original destination | 20 // to the destination location. During rollback the original destination |
19 // hierarchy is moved back. | 21 // hierarchy is moved back. |
(...skipping 13 matching lines...) Expand all Loading... |
33 // Notes on temp_path: to facilitate rollback, the caller needs to supply | 35 // Notes on temp_path: to facilitate rollback, the caller needs to supply |
34 // a temporary directory to save the original files if they exist under | 36 // a temporary directory to save the original files if they exist under |
35 // dest_path. | 37 // dest_path. |
36 CopyTreeWorkItem(const std::wstring& source_path, | 38 CopyTreeWorkItem(const std::wstring& source_path, |
37 const std::wstring& dest_path, | 39 const std::wstring& dest_path, |
38 const std::wstring& temp_dir, | 40 const std::wstring& temp_dir, |
39 CopyOverWriteOption overwrite_option, | 41 CopyOverWriteOption overwrite_option, |
40 const std::wstring& alternative_path); | 42 const std::wstring& alternative_path); |
41 | 43 |
42 // Checks if the path specified is in use (and hence can not be deleted) | 44 // Checks if the path specified is in use (and hence can not be deleted) |
43 bool IsFileInUse(const std::wstring& path); | 45 bool IsFileInUse(const FilePath& path); |
44 | 46 |
45 // Get a backup path that can keep the original files under dest_path_, | 47 // Get a backup path that can keep the original files under dest_path_, |
46 // and set backup_path_ with the result. | 48 // and set backup_path_ with the result. |
47 bool GetBackupPath(); | 49 bool GetBackupPath(); |
48 | 50 |
49 // Source path to copy files from. | 51 // Source path to copy files from. |
50 std::wstring source_path_; | 52 FilePath source_path_; |
51 | 53 |
52 // Destination path to copy files to. | 54 // Destination path to copy files to. |
53 std::wstring dest_path_; | 55 FilePath dest_path_; |
54 | 56 |
55 // Temporary directory that can be used. | 57 // Temporary directory that can be used. |
56 std::wstring temp_dir_; | 58 FilePath temp_dir_; |
57 | 59 |
58 // Controls the behavior for overwriting. | 60 // Controls the behavior for overwriting. |
59 CopyOverWriteOption overwrite_option_; | 61 CopyOverWriteOption overwrite_option_; |
60 | 62 |
61 // If overwrite_option_ = NEW_NAME_IF_IN_USE, this variables stores the path | 63 // If overwrite_option_ = NEW_NAME_IF_IN_USE, this variables stores the path |
62 // to be used if the file is in use and hence we want to copy it to a | 64 // to be used if the file is in use and hence we want to copy it to a |
63 // different path. | 65 // different path. |
64 std::wstring alternative_path_; | 66 FilePath alternative_path_; |
65 | 67 |
66 // Whether the source was copied to dest_path_ | 68 // Whether the source was copied to dest_path_ |
67 bool copied_to_dest_path_; | 69 bool copied_to_dest_path_; |
68 | 70 |
69 // Whether the original files have been moved to backup path under | 71 // Whether the original files have been moved to backup path under |
70 // temporary directory. If true, moving back is needed during rollback. | 72 // temporary directory. If true, moving back is needed during rollback. |
71 bool moved_to_backup_; | 73 bool moved_to_backup_; |
72 | 74 |
73 // Whether the source was copied to alternative_path_ because dest_path_ | 75 // Whether the source was copied to alternative_path_ because dest_path_ |
74 // existed and was in use. Needed during rollback. | 76 // existed and was in use. Needed during rollback. |
75 bool copied_to_alternate_path_; | 77 bool copied_to_alternate_path_; |
76 | 78 |
77 // The full path in temporary directory that the original dest_path_ has | 79 // The full path in temporary directory that the original dest_path_ has |
78 // been moved to. | 80 // been moved to. |
79 std::wstring backup_path_; | 81 FilePath backup_path_; |
80 }; | 82 }; |
81 | 83 |
82 #endif // CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ | 84 #endif // CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ |
OLD | NEW |