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

Unified Diff: net/disk_cache/disk_cache_test_base.cc

Issue 6292011: Disk cache: Prevent obscure file corruption and deal... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
Index: net/disk_cache/disk_cache_test_base.cc
===================================================================
--- net/disk_cache/disk_cache_test_base.cc (revision 71365)
+++ net/disk_cache/disk_cache_test_base.cc (working copy)
@@ -236,3 +236,32 @@
int rv = entry->WriteSparseData(offset, buf, len, &cb);
return cb.GetResult(rv);
}
+
+// Simple task to run part of a test from the cache thread.
+class TrimTask : public Task {
+ public:
+ TrimTask(disk_cache::BackendImpl* backend, bool deleted, bool empty)
+ : backend_(backend),
+ deleted_(deleted),
+ empty_(empty) {}
+
+ virtual void Run() {
+ if (deleted_)
+ backend_->TrimDeletedListForTest(empty_);
+ else
+ backend_->TrimForTest(empty_);
+ }
+
+ protected:
+ disk_cache::BackendImpl* backend_;
+ bool deleted_;
+ bool empty_;
+};
+
+void DiskCacheTestWithCache::TrimForTest(bool empty) {
+ RunTaskForTest(new TrimTask(cache_impl_, false, empty));
+}
+
+void DiskCacheTestWithCache::TrimDeletedListForTest(bool empty) {
+ RunTaskForTest(new TrimTask(cache_impl_, true, empty));
+}

Powered by Google App Engine
This is Rietveld 408576698