diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-26 22:08:21 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-26 22:08:21 +0000 |
commit | 50a10dfb81940d6907b1add46e0abdedce34ff27 (patch) | |
tree | 1c3572c0f646554d290d534333f6fe5861362ebb /net/disk_cache | |
parent | 7b8fd35ead1d0bd04ed3ad2be7a47133169765c8 (diff) | |
download | chromium_src-50a10dfb81940d6907b1add46e0abdedce34ff27.zip chromium_src-50a10dfb81940d6907b1add46e0abdedce34ff27.tar.gz chromium_src-50a10dfb81940d6907b1add46e0abdedce34ff27.tar.bz2 |
Disk cache: Make sure that we don't leak file handles (even on leaky tests)
because that may cause failures with other tests.
BUG=122005
TEST=net_unittests
Review URL: https://chromiumcodereview.appspot.com/10140031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134160 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r-- | net/disk_cache/backend_unittest.cc | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index ea617fd..fd62ca3 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -280,6 +280,7 @@ TEST_F(DiskCacheBackendTest, ExternalFiles) { // Tests that we deal with file-level pending operations at destruction time. void DiskCacheBackendTest::BackendShutdownWithPendingFileIO(bool fast) { net::TestCompletionCallback cb; + int rv; { ASSERT_TRUE(CleanupCacheDir()); @@ -291,10 +292,10 @@ void DiskCacheBackendTest::BackendShutdownWithPendingFileIO(bool fast) { uint32 flags = disk_cache::kNoBuffering; if (!fast) flags |= disk_cache::kNoRandom; - int rv = disk_cache::BackendImpl::CreateBackend( - cache_path_, false, 0, net::DISK_CACHE, flags, - base::MessageLoopProxy::current(), NULL, - &cache, cb.callback()); + rv = disk_cache::BackendImpl::CreateBackend( + cache_path_, false, 0, net::DISK_CACHE, flags, + base::MessageLoopProxy::current(), NULL, + &cache, cb.callback()); ASSERT_EQ(net::OK, cb.GetResult(rv)); disk_cache::EntryImpl* entry; @@ -333,6 +334,14 @@ void DiskCacheBackendTest::BackendShutdownWithPendingFileIO(bool fast) { } MessageLoop::current()->RunAllPending(); + +#if defined(OS_WIN) + // Wait for the actual operation to complete, or we'll keep a file handle that + // may cause issues later. Note that on Posix systems even though this test + // uses a single thread, the actual IO is posted to a worker thread and the + // cache destructor breaks the link to reach cb when the operation completes. + rv = cb.GetResult(rv); +#endif } TEST_F(DiskCacheBackendTest, ShutdownWithPendingFileIO) { @@ -370,16 +379,9 @@ void DiskCacheBackendTest::BackendShutdownWithPendingIO(bool fast) { rv = cache->CreateEntry("some key", &entry, cb.callback()); ASSERT_EQ(net::OK, cb.GetResult(rv)); - const int kSize = 25000; - scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize)); - CacheTestFillBuffer(buffer->data(), kSize, false); - - rv = entry->WriteData(0, 0, buffer, kSize, cb.callback(), false); - EXPECT_EQ(net::ERR_IO_PENDING, rv); - entry->Close(); - // The cache destructor will see two pending operations here. + // The cache destructor will see one pending operation here. delete cache; } |