Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Side by Side Diff: chrome/installer/util/delete_tree_work_item.h

Issue 6538025: Temp dir cleanup:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
10
11 #include <string>
12 #include <utility>
13 #include <vector> 9 #include <vector>
14 10
15 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/scoped_ptr.h"
13 #include "base/scoped_temp_dir.h"
16 #include "chrome/installer/util/work_item.h" 14 #include "chrome/installer/util/work_item.h"
17 15
18 // A WorkItem subclass that recursively deletes a file system hierarchy at the 16 // A WorkItem subclass that recursively deletes a file system hierarchy at the
19 // given root path. The file system hierarchy could be a single file, or a 17 // given root path. The file system hierarchy could be a single file, or a
20 // directory. 18 // directory.
21 // The file system hierarchy to be deleted can have a key file. If the key file 19 // The file system hierarchy to be deleted can have one or more key files. If
22 // is specified, deletion will be performed only if the key file is not in use. 20 // specified, deletion will be performed only if all key files are not in use.
23 class DeleteTreeWorkItem : public WorkItem { 21 class DeleteTreeWorkItem : public WorkItem {
24 public: 22 public:
25 virtual ~DeleteTreeWorkItem(); 23 virtual ~DeleteTreeWorkItem();
26 24
27 virtual bool Do(); 25 virtual bool Do();
28 26
29 virtual void Rollback(); 27 virtual void Rollback();
30 28
31 private: 29 private:
32 friend class WorkItem; 30 friend class WorkItem;
33 31
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_
40 bool GetBackupPath(const FilePath& for_path, FilePath* backup_path);
41
42 DeleteTreeWorkItem(const FilePath& root_path, 32 DeleteTreeWorkItem(const FilePath& root_path,
33 const FilePath& temp_path,
43 const std::vector<FilePath>& key_paths); 34 const std::vector<FilePath>& key_paths);
44 35
45 // Root path to delete. 36 // Root path to delete.
46 FilePath root_path_; 37 FilePath root_path_;
47 38
48 // Contains the path to key files and their backups once Do() has been called. 39 // Temporary directory that can be used.
49 // If key files are specified, deletion will be performed only if none of the 40 FilePath temp_path_;
50 // key files are in use.
51 KeyFileList key_paths_;
52 41
53 // The full path in temporary directory that the original root_path_ has 42 // The number of key files.
54 // been moved to. 43 ptrdiff_t num_key_files_;
55 FilePath backup_path_; 44
45 // Contains the paths to the key files. If specified, deletion will be
46 // performed only if none of the key files are in use.
47 scoped_array<FilePath> key_paths_;
48
49 // Contains the temp directories for the backed-up key files. The directories
50 // are created and populated in Do() as-needed. We don't use a standard
51 // container for this since ScopedTempDir isn't CopyConstructible.
52 scoped_array<ScopedTempDir> key_backup_paths_;
53
54 // The temporary directory into which the original root_path_ has been moved.
55 ScopedTempDir backup_path_;
56 }; 56 };
57 57
58 #endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_ 58 #endif // CHROME_INSTALLER_UTIL_DELETE_TREE_WORK_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698