summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_request_handler_unittest.cc
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-19 00:38:56 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-19 00:38:56 +0000
commit79b15b23db23e5c7722258d0b227959be7ac387c (patch)
tree412e984c99342c6e6bedf4a5d4ac0766fe8210df /webkit/appcache/appcache_request_handler_unittest.cc
parent26d8e64e28eacee2118834aad825c3752d239c5d (diff)
downloadchromium_src-79b15b23db23e5c7722258d0b227959be7ac387c.zip
chromium_src-79b15b23db23e5c7722258d0b227959be7ac387c.tar.gz
chromium_src-79b15b23db23e5c7722258d0b227959be7ac387c.tar.bz2
AppCache*Test: do not use ScopedRunnableMethodFactory from multiple threads.
The event_ signaling should already prevent the testcase from being deleted before the test is done, so we can just post the tasks directly. BUG=24715 TEST=tools/valgrind/chrome_tests.sh --tool=tsan -t test_shell --gtest_filter='AppCache*' Review URL: http://codereview.chromium.org/2121005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_request_handler_unittest.cc')
-rw-r--r--webkit/appcache/appcache_request_handler_unittest.cc28
1 files changed, 16 insertions, 12 deletions
diff --git a/webkit/appcache/appcache_request_handler_unittest.cc b/webkit/appcache/appcache_request_handler_unittest.cc
index 26091d9..83a0236 100644
--- a/webkit/appcache/appcache_request_handler_unittest.cc
+++ b/webkit/appcache/appcache_request_handler_unittest.cc
@@ -103,8 +103,7 @@ class AppCacheRequestHandlerTest : public testing::Test {
// Test harness --------------------------------------------------
AppCacheRequestHandlerTest()
- : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
- orig_http_factory_(NULL) {
+ : orig_http_factory_(NULL) {
}
template <class Method>
@@ -142,9 +141,8 @@ class AppCacheRequestHandlerTest : public testing::Test {
// We unwind the stack prior to finishing up to let stack
// based objects get deleted.
DCHECK(MessageLoop::current() == io_thread_->message_loop());
- MessageLoop::current()->PostTask(FROM_HERE,
- method_factory_.NewRunnableMethod(
- &AppCacheRequestHandlerTest::TestFinishedUnwound));
+ MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
+ this, &AppCacheRequestHandlerTest::TestFinishedUnwound));
}
void TestFinishedUnwound() {
@@ -169,8 +167,8 @@ class AppCacheRequestHandlerTest : public testing::Test {
// MainResource_Miss --------------------------------------------------
void MainResource_Miss() {
- PushNextTask(method_factory_.NewRunnableMethod(
- &AppCacheRequestHandlerTest::Verify_MainResource_Miss));
+ PushNextTask(NewRunnableMethod(
+ this, &AppCacheRequestHandlerTest::Verify_MainResource_Miss));
request_.reset(new MockURLRequest(GURL("http://blah/")));
handler_.reset(host_->CreateRequestHandler(request_.get(), true));
@@ -207,8 +205,8 @@ class AppCacheRequestHandlerTest : public testing::Test {
// MainResource_Hit --------------------------------------------------
void MainResource_Hit() {
- PushNextTask(method_factory_.NewRunnableMethod(
- &AppCacheRequestHandlerTest::Verify_MainResource_Hit));
+ PushNextTask(NewRunnableMethod(
+ this, &AppCacheRequestHandlerTest::Verify_MainResource_Hit));
request_.reset(new MockURLRequest(GURL("http://blah/")));
handler_.reset(host_->CreateRequestHandler(request_.get(), true));
@@ -246,8 +244,8 @@ class AppCacheRequestHandlerTest : public testing::Test {
// MainResource_Fallback --------------------------------------------------
void MainResource_Fallback() {
- PushNextTask(method_factory_.NewRunnableMethod(
- &AppCacheRequestHandlerTest::Verify_MainResource_Fallback));
+ PushNextTask(NewRunnableMethod(
+ this, &AppCacheRequestHandlerTest::Verify_MainResource_Fallback));
request_.reset(new MockURLRequest(GURL("http://blah/")));
handler_.reset(host_->CreateRequestHandler(request_.get(), true));
@@ -573,7 +571,6 @@ class AppCacheRequestHandlerTest : public testing::Test {
// Data members --------------------------------------------------
- ScopedRunnableMethodFactory<AppCacheRequestHandlerTest> method_factory_;
scoped_ptr<base::WaitableEvent> test_finished_event_;
std::stack<Task*> task_stack_;
scoped_ptr<MockAppCacheService> mock_service_;
@@ -655,3 +652,10 @@ TEST_F(AppCacheRequestHandlerTest, CanceledRequest) {
} // namespace appcache
+// AppCacheRequestHandlerTest is expected to always live longer than the
+// runnable methods. This lets us call NewRunnableMethod on its instances.
+template<>
+struct RunnableMethodTraits<appcache::AppCacheRequestHandlerTest> {
+ void RetainCallee(appcache::AppCacheRequestHandlerTest* obj) { }
+ void ReleaseCallee(appcache::AppCacheRequestHandlerTest* obj) { }
+};