Chromium Code Reviews| Index: webkit/appcache/appcache_request_handler_unittest.cc |
| diff --git a/webkit/appcache/appcache_request_handler_unittest.cc b/webkit/appcache/appcache_request_handler_unittest.cc |
| index edbda461eaf106db11c8cfc752e461d2d79267ac..61067fc34f77e52e72aefebfa29e10832c11d59d 100644 |
| --- a/webkit/appcache/appcache_request_handler_unittest.cc |
| +++ b/webkit/appcache/appcache_request_handler_unittest.cc |
| @@ -55,16 +55,17 @@ class AppCacheRequestHandlerTest : public testing::Test { |
| virtual void OnContentBlocked(int host_id, const GURL& manifest_url) {} |
| }; |
| - // Helper class run a test on our io_thread. The io_thread |
| - // is spun up once and reused for all tests. |
| + // Helper class to 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 { |
| + class MethodWrapper |
| + : public base::RefCountedThreadSafe<MethodWrapper<Method> > { |
| public: |
| - WrapperTask(AppCacheRequestHandlerTest* test, Method method) |
| + MethodWrapper(AppCacheRequestHandlerTest* test, Method method) |
| : test_(test), method_(method) { |
| } |
| - virtual void Run() { |
| + void Run() { |
| test_->SetUpTest(); |
| (test_->*method_)(); |
| } |
| @@ -72,6 +73,8 @@ class AppCacheRequestHandlerTest : public testing::Test { |
| private: |
| AppCacheRequestHandlerTest* test_; |
| Method method_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MethodWrapper); |
| }; |
| // Subclasses to simulate particular responses so test cases can |
| @@ -168,7 +171,8 @@ class AppCacheRequestHandlerTest : 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(&MethodWrapper<Method>::Run, |
|
awong
2011/12/20 23:51:47
I think this can just be base::Bind(method, base::
James Hawkins
2011/12/21 00:43:08
The wrapper calls test->SetUpTest() before calling
awong
2011/12/21 00:50:32
Gotcha. Then can we change MethodWrapper to just
|
| + new MethodWrapper<Method>(this, method))); |
| test_finished_event_->Wait(); |
| } |