diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-29 17:49:32 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-29 17:49:32 +0000 |
commit | f11c99ab635fb477bc8da138913b9aca3689f849 (patch) | |
tree | a70d26f5f75fe2a6255cc4f269517e9808fde5db /base/scoped_temp_dir.cc | |
parent | ecc45ea743daa1f7686736c37b61da97f993af20 (diff) | |
download | chromium_src-f11c99ab635fb477bc8da138913b9aca3689f849.zip chromium_src-f11c99ab635fb477bc8da138913b9aca3689f849.tar.gz chromium_src-f11c99ab635fb477bc8da138913b9aca3689f849.tar.bz2 |
Make ScopedTempDir::Delete return a bool so that its functionality can be tested.
TEST=Run the new unit test: ScopedTempDir.LockedTempDir
BUG=none
Review URL: http://codereview.chromium.org/5340004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67551 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/scoped_temp_dir.cc')
-rw-r--r-- | base/scoped_temp_dir.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/base/scoped_temp_dir.cc b/base/scoped_temp_dir.cc index 5cd13b4..000ed0a 100644 --- a/base/scoped_temp_dir.cc +++ b/base/scoped_temp_dir.cc @@ -11,7 +11,8 @@ ScopedTempDir::ScopedTempDir() { } ScopedTempDir::~ScopedTempDir() { - Delete(); + if (!path_.empty() && !Delete()) + LOG(WARNING) << "Could not delete temp dir in dtor."; } bool ScopedTempDir::CreateUniqueTempDir() { @@ -57,10 +58,19 @@ bool ScopedTempDir::Set(const FilePath& path) { return true; } -void ScopedTempDir::Delete() { - if (!path_.empty() && !file_util::Delete(path_, true)) +bool ScopedTempDir::Delete() { + if (path_.empty()) + return false; + + bool ret = file_util::Delete(path_, true); + if (ret) { + // We only clear the path if deleted the directory. + path_.clear(); + } else { LOG(ERROR) << "ScopedTempDir unable to delete " << path_.value(); - path_.clear(); + } + + return ret; } FilePath ScopedTempDir::Take() { |