| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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 #include "chrome/installer/util/work_item.h" | 10 #include "chrome/installer/util/work_item.h" |
| 11 | 11 |
| 12 // A WorkItem subclass that recursively copies a file system hierarchy from | 12 // A WorkItem subclass that recursively copies a file system hierarchy from |
| 13 // source path to destination path. It also creates all necessary intermediate | 13 // 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 | 14 // paths of the destination path if they do not exist. The file system |
| 15 // hierarchy could be a single file, or a directory. | 15 // hierarchy could be a single file, or a directory. |
| 16 // Under the cover CopyTreeWorkItem moves the destination path, if existing, | 16 // Under the cover CopyTreeWorkItem moves the destination path, if existing, |
| 17 // to the temporary directory passed in, and then copies the source hierarchy | 17 // to the temporary directory passed in, and then copies the source hierarchy |
| 18 // to the destination location. During rollback the original destination | 18 // to the destination location. During rollback the original destination |
| 19 // hierarchy is moved back. | 19 // hierarchy is moved back. |
| 20 class CopyTreeWorkItem : public WorkItem { | 20 class CopyTreeWorkItem : public WorkItem { |
| 21 public: | 21 public: |
| 22 virtual ~CopyTreeWorkItem(); | 22 virtual ~CopyTreeWorkItem(); |
| 23 | 23 |
| 24 virtual bool Do(); | 24 virtual bool Do(); |
| 25 | 25 |
| 26 virtual void Rollback(); | 26 virtual void Rollback(); |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 friend class WorkItem; | 29 friend class WorkItem; |
| 30 | 30 |
| 31 // See comments on corresponding member varibles for the semantics of | 31 // See comments on corresponding member varibles for the semantics of |
| 32 // arguments. | 32 // arguments. |
| 33 // Notes on temp_path: to facilitate rollback, the caller needs to supply | 33 // 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 | 34 // a temporary directory to save the original files if they exist under |
| 35 // dest_path. | 35 // dest_path. |
| 36 CopyTreeWorkItem(std::wstring source_path, std::wstring dest_path, | 36 CopyTreeWorkItem(const std::wstring& source_path, |
| 37 std::wstring temp_dir, CopyOverWriteOption overwrite_option, | 37 const std::wstring& dest_path, |
| 38 std::wstring alternative_path); | 38 const std::wstring& temp_dir, |
| 39 CopyOverWriteOption overwrite_option, |
| 40 const std::wstring& alternative_path); |
| 39 | 41 |
| 40 // Checks if the path specified is in use (and hence can not be deleted) | 42 // Checks if the path specified is in use (and hence can not be deleted) |
| 41 bool IsFileInUse(std::wstring path); | 43 bool IsFileInUse(const std::wstring& path); |
| 42 | 44 |
| 43 // Get a backup path that can keep the original files under dest_path_, | 45 // Get a backup path that can keep the original files under dest_path_, |
| 44 // and set backup_path_ with the result. | 46 // and set backup_path_ with the result. |
| 45 bool GetBackupPath(); | 47 bool GetBackupPath(); |
| 46 | 48 |
| 47 // Source path to copy files from. | 49 // Source path to copy files from. |
| 48 std::wstring source_path_; | 50 std::wstring source_path_; |
| 49 | 51 |
| 50 // Destination path to copy files to. | 52 // Destination path to copy files to. |
| 51 std::wstring dest_path_; | 53 std::wstring dest_path_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 70 | 72 |
| 71 // Whether the source was copied to alternative_path_ because dest_path_ | 73 // Whether the source was copied to alternative_path_ because dest_path_ |
| 72 // existed and was in use. Needed during rollback. | 74 // existed and was in use. Needed during rollback. |
| 73 bool copied_to_alternate_path_; | 75 bool copied_to_alternate_path_; |
| 74 | 76 |
| 75 // The full path in temporary directory that the original dest_path_ has | 77 // The full path in temporary directory that the original dest_path_ has |
| 76 // been moved to. | 78 // been moved to. |
| 77 std::wstring backup_path_; | 79 std::wstring backup_path_; |
| 78 }; | 80 }; |
| 79 | 81 |
| 80 #endif // CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H__ | 82 #endif // CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ |
| OLD | NEW |