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

Unified Diff: net/disk_cache/backend_unittest.cc

Issue 159643: Disk cache: Remove remaining uses of RankingsNode.pointer.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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/backend_unittest.cc
===================================================================
--- net/disk_cache/backend_unittest.cc (revision 21923)
+++ net/disk_cache/backend_unittest.cc (working copy)
@@ -50,6 +50,7 @@
void BackendTrimInvalidEntry();
void BackendTrimInvalidEntry2();
void BackendEnumerations();
+ void BackendEnumerations2();
void BackendInvalidEntryEnumeration();
void BackendFixEnumerators();
void BackendDoomRecent();
@@ -656,6 +657,50 @@
BackendEnumerations();
}
+// Verifies enumerations while entries are open.
+void DiskCacheBackendTest::BackendEnumerations2() {
+ InitCache();
+ const std::string first("first");
+ const std::string second("second");
+ disk_cache::Entry *entry1, *entry2;
+ ASSERT_TRUE(cache_->CreateEntry(first, &entry1));
+ entry1->Close();
+ ASSERT_TRUE(cache_->CreateEntry(second, &entry2));
+ entry2->Close();
+
+ // Make sure that the timestamp is not the same.
+ PlatformThread::Sleep(20);
+ ASSERT_TRUE(cache_->OpenEntry(second, &entry1));
+ void* iter = NULL;
+ ASSERT_TRUE(cache_->OpenNextEntry(&iter, &entry2));
+ ASSERT_EQ(entry2->GetKey(), second);
+
+ // Two entries and the iterator pointing at "first".
+ entry1->Close();
+ entry2->Close();
+
+ // The iterator should still be valid, se we should not crash.
+ ASSERT_TRUE(cache_->OpenNextEntry(&iter, &entry2));
+ ASSERT_EQ(entry2->GetKey(), first);
+ entry2->Close();
+ cache_->EndEnumeration(&iter);
+}
+
+TEST_F(DiskCacheBackendTest, Enumerations2) {
+ BackendEnumerations2();
+}
+
+TEST_F(DiskCacheBackendTest, NewEvictionEnumerations2) {
+ SetNewEviction();
+ BackendEnumerations2();
+}
+
+TEST_F(DiskCacheBackendTest, MemoryOnlyEnumerations2) {
+ SetMemoryOnlyMode();
+ BackendEnumerations2();
+}
+
+
// Verify handling of invalid entries while doing enumerations.
// We'll be leaking memory from this test.
void DiskCacheBackendTest::BackendInvalidEntryEnumeration() {

Powered by Google App Engine
This is Rietveld 408576698