diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-16 19:25:48 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-16 19:25:48 +0000 |
commit | 915f251d0504a176e4a612a2b2ff2b00592a8819 (patch) | |
tree | d1005c9105f1308ab05ae8e93684f43f8da50041 /net/disk_cache/entry_unittest.cc | |
parent | badc5a57fd63efdb03ce99e65d4dd9e90a2f870e (diff) | |
download | chromium_src-915f251d0504a176e4a612a2b2ff2b00592a8819.zip chromium_src-915f251d0504a176e4a612a2b2ff2b00592a8819.tar.gz chromium_src-915f251d0504a176e4a612a2b2ff2b00592a8819.tar.bz2 |
base::Bind: Remove even moar OldCompletionCallback.
BUG=none
TEST=none
R=dpapad
Review URL: http://codereview.chromium.org/8947024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114838 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_unittest.cc')
-rw-r--r-- | net/disk_cache/entry_unittest.cc | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index c537ef1..ef8ad89 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -1724,22 +1724,31 @@ TEST_F(DiskCacheEntryTest, MemoryOnlyDoomSparseEntry) { DoomSparseEntry(); } -// A OldCompletionCallback that deletes the cache from within the callback. The way -// a TestOldCompletionCallback works means that all tasks (even new ones) are -// executed by the message loop before returning to the caller so the only way -// to simulate a race is to execute what we want on the callback. -class SparseTestOldCompletionCallback : public TestOldCompletionCallback { +// A CompletionCallback wrapper that deletes the cache from within the callback. +// The way an OldCompletionCallback works means that all tasks (even new ones) +// are executed by the message loop before returning to the caller so the only +// way to simulate a race is to execute what we want on the callback. +class SparseTestCompletionCallback: public TestCompletionCallbackBase { public: - explicit SparseTestOldCompletionCallback(disk_cache::Backend* cache) - : cache_(cache) {} + explicit SparseTestCompletionCallback(disk_cache::Backend* cache) + : cache_(cache), + ALLOW_THIS_IN_INITIALIZER_LIST(callback_( + base::Bind(&SparseTestCompletionCallback::OnComplete, + base::Unretained(this)))) { + } + + const net::CompletionCallback& callback() const { return callback_; } - virtual void RunWithParams(const Tuple1<int>& params) { + private: + void OnComplete(int result) { delete cache_; - TestOldCompletionCallback::RunWithParams(params); + SetResult(result); } - private: + disk_cache::Backend* cache_; - DISALLOW_COPY_AND_ASSIGN(SparseTestOldCompletionCallback); + net::CompletionCallback callback_; + + DISALLOW_COPY_AND_ASSIGN(SparseTestCompletionCallback); }; // Tests that we don't crash when the backend is deleted while we are working @@ -1765,8 +1774,8 @@ TEST_F(DiskCacheEntryTest, DoomSparseEntry2) { EXPECT_EQ(9, cache_->GetEntryCount()); entry->Close(); - SparseTestOldCompletionCallback cb(cache_); - int rv = cache_->DoomEntry(key, &cb); + SparseTestCompletionCallback cb(cache_); + int rv = cache_->DoomEntry(key, cb.callback()); EXPECT_EQ(net::ERR_IO_PENDING, rv); EXPECT_EQ(net::OK, cb.WaitForResult()); |