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

Unified Diff: net/disk_cache/disk_cache_test_util.cc

Issue 45061: Disk cache: Add a unit test that instantiates three caches... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/disk_cache_test_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/disk_cache_test_util.cc
===================================================================
--- net/disk_cache/disk_cache_test_util.cc (revision 12520)
+++ net/disk_cache/disk_cache_test_util.cc (working copy)
@@ -14,6 +14,20 @@
using base::Time;
using base::TimeDelta;
+namespace {
+
+std::wstring BuildCachePath(const std::wstring name) {
Alpha Left Google 2009/03/26 00:08:12 Can we name this function GetCachePath(const std::
+ std::wstring path;
+ PathService::Get(base::DIR_TEMP, &path);
+ file_util::AppendToPath(&path, 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);
@@ -40,13 +54,7 @@
}
std::wstring GetCachePath() {
- std::wstring path;
- PathService::Get(base::DIR_TEMP, &path);
- file_util::AppendToPath(&path, L"cache_test");
- if (!file_util::PathExists(path))
- file_util::CreateDirectory(path);
-
- return path;
+ return BuildCachePath(L"cache_test");
}
bool CreateCacheTestFile(const wchar_t* name) {
@@ -83,6 +91,12 @@
DCHECK(result);
}
+ScopedTestCache::ScopedTestCache(const std::wstring& name)
+ : path_(BuildCachePath(name)) {
+ bool result = DeleteCache(path_.c_str());
+ DCHECK(result);
+}
+
ScopedTestCache::~ScopedTestCache() {
file_util::Delete(path(), true);
}
« no previous file with comments | « net/disk_cache/disk_cache_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698