Index: net/disk_cache/disk_cache_test_util.cc |
diff --git a/net/disk_cache/disk_cache_test_util.cc b/net/disk_cache/disk_cache_test_util.cc |
index 7dd618a7b0c2c9f967190dd6ef5b07acc40fb865..095b6932106eba53c443339d28011ff74745c9ea 100644 |
--- a/net/disk_cache/disk_cache_test_util.cc |
+++ b/net/disk_cache/disk_cache_test_util.cc |
@@ -16,20 +16,6 @@ |
using base::Time; |
using base::TimeDelta; |
-namespace { |
- |
-FilePath BuildCachePath(const std::string& name) { |
- FilePath path; |
- PathService::Get(base::DIR_TEMP, &path); // Ignore return value; |
- path = path.AppendASCII(name); |
- if (!file_util::PathExists(path)) |
- file_util::CreateDirectory(path); |
- |
- return path; |
-} |
- |
-} // namespace. |
- |
std::string GenerateKey(bool same_length) { |
char key[200]; |
CacheTestFillBuffer(key, sizeof(key), same_length); |
@@ -55,10 +41,6 @@ void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls) { |
buffer[0] = 'g'; |
} |
-FilePath GetCacheFilePath() { |
- return BuildCachePath("cache_test"); |
-} |
- |
bool CreateCacheTestFile(const FilePath& name) { |
int flags = base::PLATFORM_FILE_CREATE_ALWAYS | |
base::PLATFORM_FILE_READ | |
@@ -78,7 +60,7 @@ bool DeleteCache(const FilePath& path) { |
return true; |
} |
-bool CopyTestCache(const std::string& name) { |
+bool CopyTestCache(const std::string& name, const FilePath& destination) { |
FilePath path; |
PathService::Get(base::DIR_SOURCE_ROOT, &path); |
path = path.AppendASCII("net"); |
@@ -86,10 +68,9 @@ bool CopyTestCache(const std::string& name) { |
path = path.AppendASCII("cache_tests"); |
path = path.AppendASCII(name); |
- FilePath dest = GetCacheFilePath(); |
- if (!DeleteCache(dest)) |
+ if (!DeleteCache(destination)) |
return false; |
- return file_util::CopyDirectory(path, dest, false); |
+ return file_util::CopyDirectory(path, destination, false); |
} |
bool CheckCacheIntegrity(const FilePath& path, bool new_eviction) { |
@@ -105,19 +86,11 @@ bool CheckCacheIntegrity(const FilePath& path, bool new_eviction) { |
return cache->SelfCheck() >= 0; |
} |
-ScopedTestCache::ScopedTestCache() : path_(GetCacheFilePath()) { |
- bool result = DeleteCache(path_); |
- DCHECK(result); |
-} |
- |
-ScopedTestCache::ScopedTestCache(const std::string& name) |
- : path_(BuildCachePath(name)) { |
- bool result = DeleteCache(path_); |
- DCHECK(result); |
+ScopedTestCache::ScopedTestCache() { |
+ temp_dir_.CreateUniqueTempDir(); |
} |
ScopedTestCache::~ScopedTestCache() { |
- file_util::Delete(path(), true); |
} |
// ----------------------------------------------------------------------- |