Remove obsolete for_web_contents parameter in FontRenderParamsQuery.
[chromium-blink-merge.git] / chrome / installer / util / self_cleaning_temp_dir.h
blobe473aeccb2a1aa935823afc55e2428a4dac4f236
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_INSTALLER_UTIL_SELF_CLEANING_TEMP_DIR_H_
6 #define CHROME_INSTALLER_UTIL_SELF_CLEANING_TEMP_DIR_H_
8 #include "base/basictypes.h"
9 #include "base/files/file_path.h"
10 #include "base/gtest_prod_util.h"
12 namespace installer {
14 // A helper class for managing a temporary directory. In relation to
15 // base::ScopedTempDir, this class additionally cleans up all non-empty parent
16 // directories of the temporary directory that are created by an instance.
17 class SelfCleaningTempDir {
18 public:
19 typedef base::FilePath::StringType StringType;
21 SelfCleaningTempDir();
23 // Performs a Delete().
24 ~SelfCleaningTempDir();
26 // Creates a temporary directory named |temp_name| under |parent_dir|,
27 // creating intermediate directories as needed.
28 bool Initialize(const base::FilePath& parent_dir,
29 const StringType& temp_name);
31 // Returns the temporary directory created in Initialize().
32 const base::FilePath& path() const { return temp_dir_; }
34 // Deletes the temporary directory created in Initialize() and all of its
35 // contents, as well as all empty intermediate directories. Any of these that
36 // cannot be deleted immediately are scheduled for deletion upon reboot.
37 bool Delete();
39 private:
40 static void GetTopDirToCreate(const base::FilePath& temp_parent_dir,
41 base::FilePath* base_dir);
43 // The topmost directory created.
44 base::FilePath base_dir_;
46 // The temporary directory.
47 base::FilePath temp_dir_;
49 FRIEND_TEST_ALL_PREFIXES(SelfCleaningTempDirTest, TopLevel);
50 FRIEND_TEST_ALL_PREFIXES(SelfCleaningTempDirTest, TopLevelPlusOne);
51 DISALLOW_COPY_AND_ASSIGN(SelfCleaningTempDir);
54 } // namespace installer
56 #endif // CHROME_INSTALLER_UTIL_SELF_CLEANING_TEMP_DIR_H_