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

Unified Diff: content/browser/cache_storage/cache_storage_manager_unittest.cc

Issue 1421863002: [CacheStorage] Garbage collect unreferenced caches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@random_cache_name
Patch Set: Address comments from PS2 Created 5 years, 2 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 | « content/browser/cache_storage/cache_storage_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/cache_storage/cache_storage_manager_unittest.cc
diff --git a/content/browser/cache_storage/cache_storage_manager_unittest.cc b/content/browser/cache_storage/cache_storage_manager_unittest.cc
index 04c6a6a87a74600a95a6ab76da358dd66f13dc12..4c3758441db9806fe808e40dace22f623abc1d74 100644
--- a/content/browser/cache_storage/cache_storage_manager_unittest.cc
+++ b/content/browser/cache_storage/cache_storage_manager_unittest.cc
@@ -655,6 +655,31 @@ TEST_F(CacheStorageManagerTest, MemoryBackedSizePersistent) {
EXPECT_EQ(0, cache_storage->MemoryBackedSize());
}
+TEST_F(CacheStorageManagerTest, DeleteUnreferencedCacheDirectories) {
+ // Create a referenced cache.
+ EXPECT_TRUE(Open(origin1_, "foo"));
+ EXPECT_TRUE(CachePut(callback_cache_, GURL("http://example.com/foo")));
+
+ // Create an unreferenced directory next to the referenced one.
+ base::FilePath origin_path = CacheStorageManager::ConstructOriginPath(
+ cache_manager_->root_path(), origin1_);
+ base::FilePath unreferenced_path = origin_path.AppendASCII("bar");
+ EXPECT_TRUE(CreateDirectory(unreferenced_path));
+ EXPECT_TRUE(base::DirectoryExists(unreferenced_path));
+
+ // Create a new StorageManager so that the next time the cache is opened
+ // the unreferenced directory can be deleted.
+ quota_manager_proxy_->SimulateQuotaManagerDestroyed();
+ cache_manager_ = CacheStorageManager::Create(cache_manager_.get());
+
+ // Verify that the referenced cache still works.
+ EXPECT_TRUE(Open(origin1_, "foo"));
+ EXPECT_TRUE(CacheMatch(callback_cache_, GURL("http://example.com/foo")));
+
+ // Verify that the unreferenced cache is gone.
+ EXPECT_FALSE(base::DirectoryExists(unreferenced_path));
+}
+
class CacheStorageMigrationTest : public CacheStorageManagerTest {
protected:
CacheStorageMigrationTest() : cache1_("foo"), cache2_("bar") {}
« no previous file with comments | « content/browser/cache_storage/cache_storage_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698