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

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

Issue 1882923003: Add best-effort/allow rollback flags on WorkItem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simple_list_tests
Patch Set: fix build error Created 4 years, 7 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
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_CREATE_DIR_WORK_ITEM_H_ 5 #ifndef CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_
6 #define CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_ 6 #define CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "chrome/installer/util/work_item.h" 11 #include "chrome/installer/util/work_item.h"
12 12
13 // A WorkItem subclass that creates a directory with the specified path. 13 // A WorkItem subclass that creates a directory with the specified path.
14 // It also creates all necessary intermediate paths if they do not exist. 14 // It also creates all necessary intermediate paths if they do not exist.
15 class CreateDirWorkItem : public WorkItem { 15 class CreateDirWorkItem : public WorkItem {
16 public: 16 public:
17 ~CreateDirWorkItem() override; 17 ~CreateDirWorkItem() override;
18 18
19 bool Do() override;
20
21 // Rollback tries to remove all directories created along the path.
22 // If the leaf directory or one of the intermediate directories are not
23 // empty, the non-empty directory and its parent directories will not be
24 // removed.
25 void Rollback() override;
26
27 private: 19 private:
28 friend class WorkItem; 20 friend class WorkItem;
29 21
30 explicit CreateDirWorkItem(const base::FilePath& path); 22 explicit CreateDirWorkItem(const base::FilePath& path);
31 23
24 // WorkItem:
25 bool DoImpl() override;
26
27 // Rollback tries to remove all directories created along the path.
28 // If the leaf directory or one of the intermediate directories are not
29 // empty, the non-empty directory and its parent directories will not be
30 // removed.
31 void RollbackImpl() override;
32
32 // Get the top most directory that needs to be created in order to create 33 // Get the top most directory that needs to be created in order to create
33 // "path_", and set "top_path_" accordingly. if "path_" already exists, 34 // "path_", and set "top_path_" accordingly. if "path_" already exists,
34 // "top_path_" is set to empty string. 35 // "top_path_" is set to empty string.
35 void GetTopDirToCreate(); 36 void GetTopDirToCreate();
36 37
37 // Path of the directory to be created. 38 // Path of the directory to be created.
38 base::FilePath path_; 39 base::FilePath path_;
39 40
40 // The top most directory that needs to be created. 41 // The top most directory that needs to be created.
41 base::FilePath top_path_; 42 base::FilePath top_path_;
42 43
43 bool rollback_needed_; 44 bool rollback_needed_;
44 }; 45 };
45 46
46 #endif // CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_ 47 #endif // CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698