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/backend_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/backend_unittest.cc')
-rw-r--r-- | net/disk_cache/backend_unittest.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index ec9b61e..ad7ff66 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -208,6 +208,39 @@ TEST_F(DiskCacheBackendTest, ExternalFiles) { EXPECT_EQ(0, memcmp(buffer1->data(), buffer2->data(), kSize)); } +TEST_F(DiskCacheTest, ShutdownWithPendingIO) { + SimpleCallbackTest callback; + + { + std::wstring path = GetCachePath(); + ASSERT_TRUE(DeleteCache(path.c_str())); + + disk_cache::Backend* cache = + disk_cache::CreateCacheBackend(path, false, 0, net::DISK_CACHE); + + disk_cache::Entry* entry; + ASSERT_TRUE(cache->CreateEntry("some key", &entry)); + + const int kSize = 25000; + scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(kSize); + CacheTestFillBuffer(buffer->data(), kSize, false); + + for (int i = 0; i < 10 * 1024 * 1024; i += 64 * 1024) { + int rv = entry->WriteData(0, i, buffer, kSize, &callback, false); + if (rv == net::ERR_IO_PENDING) + break; + EXPECT_EQ(kSize, rv); + } + + entry->Close(); + + // The cache destructor will see one pending operation here. + delete cache; + } + + MessageLoop::current()->RunAllPending(); +} + void DiskCacheBackendTest::BackendSetSize() { SetDirectMode(); const int cache_size = 0x10000; // 64 kB |