diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-22 05:10:24 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-22 05:10:24 +0000 |
commit | 72a3ce556f70637bfa196901c92652d023b96f7f (patch) | |
tree | f62634f2d3f4faf2aec3d2231de59d63f96ccd36 /webkit/appcache/appcache_storage_impl_unittest.cc | |
parent | 0c7ae740f862bae6dc245d378b9bc515f62e73ab (diff) | |
download | chromium_src-72a3ce556f70637bfa196901c92652d023b96f7f.zip chromium_src-72a3ce556f70637bfa196901c92652d023b96f7f.tar.gz chromium_src-72a3ce556f70637bfa196901c92652d023b96f7f.tar.bz2 |
base::Bind: More low-hanging fruit in webkit/appcache.
BUG=none
TEST=none
R=csilv
Review URL: http://codereview.chromium.org/8949063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_storage_impl_unittest.cc')
-rw-r--r-- | webkit/appcache/appcache_storage_impl_unittest.cc | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/webkit/appcache/appcache_storage_impl_unittest.cc b/webkit/appcache/appcache_storage_impl_unittest.cc index cfaabf2..cdfe149 100644 --- a/webkit/appcache/appcache_storage_impl_unittest.cc +++ b/webkit/appcache/appcache_storage_impl_unittest.cc @@ -202,37 +202,27 @@ class AppCacheStorageImplTest : public testing::Test { scoped_refptr<MockQuotaManager> mock_manager_; }; - // Helper class run a test on our io_thread. The io_thread - // is spun up once and reused for all tests. template <class Method> - class WrapperTask : public Task { - public: - WrapperTask(AppCacheStorageImplTest* test, Method method) - : test_(test), method_(method) { - } - - virtual void Run() OVERRIDE { - test_->SetUpTest(); - - // Ensure InitTask execution prior to conducting a test. - test_->FlushDbThreadTasks(); - - // We also have to wait for InitTask completion call to be performed - // on the IO thread prior to running the test. Its guaranteed to be - // queued by this time. - MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&RunMethod, test_, method_)); - } + void RunMethod(Method method) { + (this->*method)(); + } - static void RunMethod(AppCacheStorageImplTest* test, Method method) { - (test->*method)(); - } + // Helper callback to run a test on our io_thread. The io_thread is spun up + // once and reused for all tests. + template <class Method> + void MethodWrapper(Method method) { + SetUpTest(); - private: - AppCacheStorageImplTest* test_; - Method method_; - }; + // Ensure InitTask execution prior to conducting a test. + FlushDbThreadTasks(); + // We also have to wait for InitTask completion call to be performed + // on the IO thread prior to running the test. Its guaranteed to be + // queued by this time. + MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&AppCacheStorageImplTest::RunMethod<Method>, + base::Unretained(this), method)); + } static void SetUpTestCase() { io_thread.reset(new base::Thread("AppCacheTest.IOThread")); @@ -257,7 +247,8 @@ class AppCacheStorageImplTest : public testing::Test { void RunTestOnIOThread(Method method) { test_finished_event_ .reset(new base::WaitableEvent(false, false)); io_thread->message_loop()->PostTask( - FROM_HERE, new WrapperTask<Method>(this, method)); + FROM_HERE, base::Bind(&AppCacheStorageImplTest::MethodWrapper<Method>, + base::Unretained(this), method)); test_finished_event_->Wait(); } |