Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: webkit/appcache/appcache_request_handler_unittest.cc

Issue 8991001: base::Bind: Convert most of webkit/appcache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang fix. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
}

Powered by Google App Engine
This is Rietveld 408576698