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

Side by Side Diff: base/scoped_temp_dir.h

Issue 2838034: Move the SingletonSocket to a temporary directory (Closed)
Patch Set: Address mattm's comments Created 10 years, 4 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
« no previous file with comments | « no previous file | base/scoped_temp_dir.cc » ('j') | chrome/browser/process_singleton.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 BASE_SCOPED_TEMP_DIR_H_ 5 #ifndef BASE_SCOPED_TEMP_DIR_H_
6 #define BASE_SCOPED_TEMP_DIR_H_ 6 #define BASE_SCOPED_TEMP_DIR_H_
7 #pragma once 7 #pragma once
8 8
9 // An object representing a temporary / scratch directory that should be cleaned 9 // An object representing a temporary / scratch directory that should be cleaned
10 // up (recursively) when this object goes out of scope. Note that since 10 // up (recursively) when this object goes out of scope. Note that since
11 // deletion occurs during the destructor, no further error handling is possible 11 // deletion occurs during the destructor, no further error handling is possible
12 // if the directory fails to be deleted. As a result, deletion is not 12 // if the directory fails to be deleted. As a result, deletion is not
13 // guaranteed by this class. 13 // guaranteed by this class.
14 14
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 16
17 class ScopedTempDir { 17 class ScopedTempDir {
18 public: 18 public:
19 // No directory is owned/created initially. 19 // No directory is owned/created initially.
20 ScopedTempDir(); 20 ScopedTempDir();
21 21
22 // Recursively delete path_ 22 // Recursively delete path.
23 ~ScopedTempDir(); 23 ~ScopedTempDir();
24 24
25 // Creates a unique directory in TempPath, and takes ownership of it. 25 // Creates a unique directory in TempPath, and takes ownership of it.
26 // See file_util::CreateNewTemporaryDirectory. 26 // See file_util::CreateNewTemporaryDirectory.
27 bool CreateUniqueTempDir(); 27 bool CreateUniqueTempDir();
28 28
29 // Creates a unique directory under a given path, and takes ownership of it. 29 // Creates a unique directory under a given path, and takes ownership of it.
30 bool CreateUniqueTempDirUnderPath(const FilePath& path); 30 bool CreateUniqueTempDirUnderPath(const FilePath& path);
31 31
32 // Takes ownership of directory at |path|, creating it if necessary. 32 // Takes ownership of directory at |path|, creating it if necessary.
33 // Don't call multiple times unless Take() has been called first. 33 // Don't call multiple times unless Take() has been called first.
34 bool Set(const FilePath& path); 34 bool Set(const FilePath& path);
35 35
36 // Deletes the temporary directory wrapped by this object.
37 void Delete();
38
36 // Caller takes ownership of the temporary directory so it won't be destroyed 39 // Caller takes ownership of the temporary directory so it won't be destroyed
37 // when this object goes out of scope. 40 // when this object goes out of scope.
38 FilePath Take(); 41 FilePath Take();
39 42
40 const FilePath& path() const { return path_; } 43 const FilePath& path() const { return path_; }
41 44
42 // Returns true if path_ is non-empty and exists. 45 // Returns true if path_ is non-empty and exists.
43 bool IsValid() const; 46 bool IsValid() const;
44 47
45 private: 48 private:
46 FilePath path_; 49 FilePath path_;
47 50
48 DISALLOW_COPY_AND_ASSIGN(ScopedTempDir); 51 DISALLOW_COPY_AND_ASSIGN(ScopedTempDir);
49 }; 52 };
50 53
51 #endif // BASE_SCOPED_TEMP_DIR_H_ 54 #endif // BASE_SCOPED_TEMP_DIR_H_
OLDNEW
« no previous file with comments | « no previous file | base/scoped_temp_dir.cc » ('j') | chrome/browser/process_singleton.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698