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

Unified Diff: net/tools/crash_cache/crash_cache.cc

Issue 8637022: Disk cache: Update the remove/insert data files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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/data/cache_tests/remove_tail3/index ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/crash_cache/crash_cache.cc
===================================================================
--- net/tools/crash_cache/crash_cache.cc (revision 110241)
+++ net/tools/crash_cache/crash_cache.cc (working copy)
@@ -132,15 +132,22 @@
cb.GetResult(rv); // Ignore the result;
}
+bool CreateCache(const FilePath& path, base::Thread* thread,
+ disk_cache::Backend** cache, TestOldCompletionCallback* cb) {
+ int size = 1024 * 1024;
+ int rv = disk_cache::BackendImpl::CreateBackend(
+ path, false, size, net::DISK_CACHE, disk_cache::kNoRandom,
+ thread->message_loop_proxy(), NULL, cache, cb);
+
+ return (cb->GetResult(rv) == net::OK && !(*cache)->GetEntryCount());
+}
gavinp 2011/11/28 16:15:01 I take it that crash_cache.cc had bitrotted becaus
rvargas (doing something else) 2011/11/28 19:06:18 Kind of. Without this change, it sometimes generat
+
// Generates the files for an empty and one item cache.
int SimpleInsert(const FilePath& path, RankCrashes action,
base::Thread* cache_thread) {
TestOldCompletionCallback cb;
disk_cache::Backend* cache;
- int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, path, 0, false,
- cache_thread->message_loop_proxy(),
- NULL, &cache, &cb);
- if (cb.GetResult(rv) != net::OK || cache->GetEntryCount())
+ if (!CreateCache(path, cache_thread, &cache, &cb))
return GENERIC;
const char* test_name = "some other key";
@@ -151,7 +158,7 @@
}
disk_cache::Entry* entry;
- rv = cache->CreateEntry(test_name, &entry, &cb);
+ int rv = cache->CreateEntry(test_name, &entry, &cb);
if (cb.GetResult(rv) != net::OK)
return GENERIC;
@@ -177,15 +184,11 @@
TestOldCompletionCallback cb;
disk_cache::Backend* cache;
- // Use a simple LRU for eviction.
- int rv = disk_cache::CreateCacheBackend(net::MEDIA_CACHE, path, 0, false,
- cache_thread->message_loop_proxy(),
- NULL, &cache, &cb);
- if (cb.GetResult(rv) != net::OK || cache->GetEntryCount())
+ if (!CreateCache(path, cache_thread, &cache, &cb))
return GENERIC;
disk_cache::Entry* entry;
- rv = cache->CreateEntry(kCrashEntryName, &entry, &cb);
+ int rv = cache->CreateEntry(kCrashEntryName, &entry, &cb);
if (cb.GetResult(rv) != net::OK)
return GENERIC;
@@ -220,15 +223,11 @@
TestOldCompletionCallback cb;
disk_cache::Backend* cache;
- // Use a simple LRU for eviction.
- int rv = disk_cache::CreateCacheBackend(net::MEDIA_CACHE, path, 0, false,
- cache_thread->message_loop_proxy(),
- NULL, &cache, &cb);
- if (cb.GetResult(rv) != net::OK || cache->GetEntryCount())
+ if (!CreateCache(path, cache_thread, &cache, &cb))
return GENERIC;
disk_cache::Entry* entry;
- rv = cache->CreateEntry("some other key", &entry, &cb);
+ int rv = cache->CreateEntry("some other key", &entry, &cb);
if (cb.GetResult(rv) != net::OK)
return GENERIC;
@@ -264,6 +263,8 @@
if (!cache || !cache->SetMaxSize(0x100000))
return GENERIC;
+ // No experiments and use a simple LRU.
+ cache->SetFlags(disk_cache::kNoRandom);
TestOldCompletionCallback cb;
int rv = cache->Init(&cb);
if (cb.GetResult(rv) != net::OK || cache->GetEntryCount())
« no previous file with comments | « net/data/cache_tests/remove_tail3/index ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698