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/disk_cache/entry_unittest.cc

Issue 2819032: Revert 51312 - Disk cache: Switch the disk cache to use the cache_thread.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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/entry_impl.cc ('k') | net/disk_cache/eviction.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/entry_unittest.cc
===================================================================
--- net/disk_cache/entry_unittest.cc (revision 51324)
+++ net/disk_cache/entry_unittest.cc (working copy)
@@ -82,12 +82,10 @@
entry1->Doom();
entry1->Close();
- FlushQueueForTest();
EXPECT_EQ(0, cache_->GetEntryCount());
}
TEST_F(DiskCacheEntryTest, InternalSyncIO) {
- SetDirectMode();
InitCache();
InternalSyncIO();
}
@@ -225,12 +223,10 @@
entry1->Doom();
entry1->Close();
- FlushQueueForTest();
EXPECT_EQ(0, cache_->GetEntryCount());
}
TEST_F(DiskCacheEntryTest, InternalAsyncIO) {
- SetDirectMode();
InitCache();
InternalAsyncIO();
}
@@ -273,12 +269,10 @@
entry1->Doom();
entry1->Close();
- FlushQueueForTest();
EXPECT_EQ(0, cache_->GetEntryCount());
}
TEST_F(DiskCacheEntryTest, ExternalSyncIO) {
- SetDirectMode();
InitCache();
ExternalSyncIO();
}
@@ -373,21 +367,19 @@
EXPECT_TRUE(17000 == ret || net::ERR_IO_PENDING == ret);
if (net::ERR_IO_PENDING == ret)
expected++;
+ EXPECT_EQ(37000, entry1->GetDataSize(1));
EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
- EXPECT_EQ(37000, entry1->GetDataSize(1));
EXPECT_FALSE(g_cache_tests_error);
EXPECT_EQ(expected, g_cache_tests_received);
entry1->Doom();
entry1->Close();
- FlushQueueForTest();
EXPECT_EQ(0, cache_->GetEntryCount());
}
TEST_F(DiskCacheEntryTest, ExternalAsyncIO) {
- SetDirectMode();
InitCache();
ExternalAsyncIO();
}
@@ -796,12 +788,10 @@
entry1->Doom();
entry1->Close();
- FlushQueueForTest();
EXPECT_EQ(0, cache_->GetEntryCount());
}
TEST_F(DiskCacheEntryTest, DoomEntry) {
- SetDirectMode();
InitCache();
DoomNormalEntry();
}
@@ -819,7 +809,6 @@
ASSERT_EQ(net::OK, CreateEntry(key, &entry));
entry->Doom();
- FlushQueueForTest();
EXPECT_EQ(0, cache_->GetEntryCount());
Time initial = Time::Now();
PlatformThread::Sleep(20);
@@ -842,7 +831,6 @@
}
TEST_F(DiskCacheEntryTest, DoomedEntry) {
- SetDirectMode();
InitCache();
DoomedEntry();
}
@@ -1275,8 +1263,6 @@
}
TEST_F(DiskCacheEntryTest, DoomSparseEntry) {
- SetDirectMode();
- UseCurrentThread();
InitCache();
DoomSparseEntry();
}
@@ -1435,7 +1421,6 @@
}
TEST_F(DiskCacheEntryTest, CancelSparseIO) {
- UseCurrentThread();
InitCache();
std::string key("the first key");
disk_cache::Entry* entry;
@@ -1445,20 +1430,25 @@
scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(kSize);
CacheTestFillBuffer(buf->data(), kSize, false);
- // This will open and write two "real" entries.
TestCompletionCallback cb1, cb2, cb3, cb4, cb5;
- int rv = entry->WriteSparseData(1024 * 1024 - 4096, buf, kSize, &cb1);
- EXPECT_EQ(net::ERR_IO_PENDING, rv);
-
int64 offset = 0;
- rv = entry->GetAvailableRange(offset, kSize, &offset, &cb5);
- rv = cb5.GetResult(rv);
- if (!cb1.have_result()) {
- // We may or may not have finished writing to the entry. If we have not,
- // we cannot start another operation at this time.
- EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, rv);
+ int tries = 0;
+ const int maxtries = 100; // Avoid hang on infinitely fast disks.
+ for (int ret = 0; ret != net::ERR_IO_PENDING; offset += kSize * 4) {
+ ret = entry->WriteSparseData(offset, buf, kSize, &cb1);
+ if (++tries > maxtries) {
+ LOG(ERROR) << "Data writes never come back PENDING; skipping test";
+ entry->Close();
+ return;
+ }
}
+ // Cannot use the entry at this point.
+ offset = 0;
+ int rv = entry->GetAvailableRange(offset, kSize, &offset, &cb5);
+ EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, cb5.GetResult(rv));
+ EXPECT_EQ(net::OK, entry->ReadyForSparseIO(&cb2));
+
// We cancel the pending operation, and register multiple notifications.
entry->CancelSparseIO();
EXPECT_EQ(net::ERR_IO_PENDING, entry->ReadyForSparseIO(&cb2));
@@ -1466,12 +1456,13 @@
entry->CancelSparseIO(); // Should be a no op at this point.
EXPECT_EQ(net::ERR_IO_PENDING, entry->ReadyForSparseIO(&cb4));
- if (!cb1.have_result()) {
- EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED,
- entry->ReadSparseData(offset, buf, kSize, NULL));
- EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED,
- entry->WriteSparseData(offset, buf, kSize, NULL));
- }
+ offset = 0;
+ rv = entry->GetAvailableRange(offset, kSize, &offset, &cb5);
+ EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, cb5.GetResult(rv));
+ EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED,
+ entry->ReadSparseData(offset, buf, kSize, NULL));
+ EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED,
+ entry->WriteSparseData(offset, buf, kSize, NULL));
// Now see if we receive all notifications.
EXPECT_EQ(kSize, cb1.GetResult(net::ERR_IO_PENDING));
@@ -1480,6 +1471,7 @@
EXPECT_EQ(net::OK, cb4.GetResult(net::ERR_IO_PENDING));
rv = entry->GetAvailableRange(offset, kSize, &offset, &cb5);
- EXPECT_EQ(0, cb5.GetResult(rv));
+ EXPECT_EQ(kSize, cb5.GetResult(rv));
+ EXPECT_EQ(net::OK, entry->ReadyForSparseIO(&cb2));
entry->Close();
}
Property changes on: net\disk_cache\entry_unittest.cc
___________________________________________________________________
Added: svn:mergeinfo
« no previous file with comments | « net/disk_cache/entry_impl.cc ('k') | net/disk_cache/eviction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698