diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 18:35:24 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 18:35:24 +0000 |
commit | f3c56e7003ecb777c9e981e7ccc0a5c5fe9ced1e (patch) | |
tree | c7302913bc73ae2bca0d2dfa8ba87bd152e17a2e /net/disk_cache/entry_unittest.cc | |
parent | f3642e9ea5c41ae3dac690e29bad3df295bc52a9 (diff) | |
download | chromium_src-f3c56e7003ecb777c9e981e7ccc0a5c5fe9ced1e.zip chromium_src-f3c56e7003ecb777c9e981e7ccc0a5c5fe9ced1e.tar.gz chromium_src-f3c56e7003ecb777c9e981e7ccc0a5c5fe9ced1e.tar.bz2 |
Disk cache: Implement asynchronous IO for Posix.
BUG=16507
TEST=Unittests
Review URL: http://codereview.chromium.org/173170
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_unittest.cc')
-rw-r--r-- | net/disk_cache/entry_unittest.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index df5a058..32ac93d 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -99,6 +99,16 @@ void DiskCacheEntryTest::InternalAsyncIO() { ASSERT_TRUE(cache_->CreateEntry("the first key", &entry1)); ASSERT_TRUE(NULL != entry1); + // Avoid using internal buffers for the test. We have to write something to + // the entry and close it so that we flush the internal buffer to disk. After + // that, IO operations will be really hitting the disk. We don't care about + // the content, so just extending the entry is enough (all extensions zero- + // fill any holes). + EXPECT_EQ(0, entry1->WriteData(0, 15 * 1024, NULL, 0, NULL, false)); + EXPECT_EQ(0, entry1->WriteData(1, 15 * 1024, NULL, 0, NULL, false)); + entry1->Close(); + ASSERT_TRUE(cache_->OpenEntry("the first key", &entry1)); + // Let's verify that each IO goes to the right callback object. CallbackTest callback1(false); CallbackTest callback2(false); @@ -129,7 +139,7 @@ void DiskCacheEntryTest::InternalAsyncIO() { CacheTestFillBuffer(buffer2->data(), kSize2, false); CacheTestFillBuffer(buffer3->data(), kSize3, false); - EXPECT_EQ(0, entry1->ReadData(0, 0, buffer1, kSize1, &callback1)); + EXPECT_EQ(0, entry1->ReadData(0, 15 * 1024, buffer1, kSize1, &callback1)); base::strlcpy(buffer1->data(), "the data", kSize1); int expected = 0; int ret = entry1->WriteData(0, 0, buffer1, kSize1, &callback2, false); @@ -147,7 +157,7 @@ void DiskCacheEntryTest::InternalAsyncIO() { EXPECT_STREQ("the data", buffer2->data()); base::strlcpy(buffer2->data(), "The really big data goes here", kSize2); - ret = entry1->WriteData(1, 1500, buffer2, kSize2, &callback4, false); + ret = entry1->WriteData(1, 1500, buffer2, kSize2, &callback4, true); EXPECT_TRUE(5000 == ret || net::ERR_IO_PENDING == ret); if (net::ERR_IO_PENDING == ret) expected++; @@ -174,13 +184,12 @@ void DiskCacheEntryTest::InternalAsyncIO() { if (net::ERR_IO_PENDING == ret) expected++; - EXPECT_EQ(0, entry1->ReadData(1, 6500, buffer2, kSize2, &callback8)); ret = entry1->ReadData(1, 0, buffer3, kSize3, &callback9); EXPECT_TRUE(6500 == ret || net::ERR_IO_PENDING == ret); if (net::ERR_IO_PENDING == ret) expected++; - ret = entry1->WriteData(1, 0, buffer3, 8192, &callback10, false); + ret = entry1->WriteData(1, 0, buffer3, 8192, &callback10, true); EXPECT_TRUE(8192 == ret || net::ERR_IO_PENDING == ret); if (net::ERR_IO_PENDING == ret) expected++; |