diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-19 00:38:56 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-19 00:38:56 +0000 |
commit | 79b15b23db23e5c7722258d0b227959be7ac387c (patch) | |
tree | 412e984c99342c6e6bedf4a5d4ac0766fe8210df /webkit/appcache/appcache_url_request_job_unittest.cc | |
parent | 26d8e64e28eacee2118834aad825c3752d239c5d (diff) | |
download | chromium_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_url_request_job_unittest.cc')
-rw-r--r-- | webkit/appcache/appcache_url_request_job_unittest.cc | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/webkit/appcache/appcache_url_request_job_unittest.cc b/webkit/appcache/appcache_url_request_job_unittest.cc index cc4b853..330784d 100644 --- a/webkit/appcache/appcache_url_request_job_unittest.cc +++ b/webkit/appcache/appcache_url_request_job_unittest.cc @@ -161,8 +161,7 @@ class AppCacheURLRequestJobTest : public testing::Test { } AppCacheURLRequestJobTest() - : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), - ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( + : ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( this, &AppCacheURLRequestJobTest::OnReadComplete)), ALLOW_THIS_IN_INITIALIZER_LIST(read_info_callback_( this, &AppCacheURLRequestJobTest::OnReadInfoComplete)), @@ -226,8 +225,8 @@ class AppCacheURLRequestJobTest : public testing::Test { // based objects get deleted. DCHECK(MessageLoop::current() == io_thread_->message_loop()); MessageLoop::current()->PostTask(FROM_HERE, - method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::TestFinishedUnwound)); + NewRunnableMethod( + this, &AppCacheURLRequestJobTest::TestFinishedUnwound)); } void TestFinishedUnwound() { @@ -271,8 +270,8 @@ class AppCacheURLRequestJobTest : public testing::Test { IOBuffer* body, int body_len) { DCHECK(body); scoped_refptr<IOBuffer> body_ref(body); - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::WriteResponseBody, + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::WriteResponseBody, body_ref, body_len)); WriteResponseHead(head); } @@ -448,8 +447,8 @@ class AppCacheURLRequestJobTest : public testing::Test { void DeliverNetworkResponse() { // This test has async steps. - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::VerifyDeliverNetworkResponse)); + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::VerifyDeliverNetworkResponse)); AppCacheStorage* storage = service_->storage(); request_.reset( @@ -480,8 +479,8 @@ class AppCacheURLRequestJobTest : public testing::Test { void DeliverErrorResponse() { // This test has async steps. - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::VerifyDeliverErrorResponse)); + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::VerifyDeliverErrorResponse)); AppCacheStorage* storage = service_->storage(); request_.reset( @@ -517,10 +516,10 @@ class AppCacheURLRequestJobTest : public testing::Test { // 2. Use URLRequest to retrieve it. // 3. Verify we received what we expected to receive. - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::VerifyDeliverSmallAppCachedResponse)); - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::RequestAppCachedResource, false)); + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::VerifyDeliverSmallAppCachedResponse)); + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::RequestAppCachedResource, false)); writer_.reset(service_->storage()->CreateResponseWriter(GURL())); written_response_id_ = writer_->response_id(); @@ -583,10 +582,10 @@ class AppCacheURLRequestJobTest : public testing::Test { // 2. Use URLRequest to retrieve it. // 3. Verify we received what we expected to receive. - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::VerifyDeliverLargeAppCachedResponse)); - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::VerifyDeliverLargeAppCachedResponse)); + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); writer_.reset(service_->storage()->CreateResponseWriter(GURL())); written_response_id_ = writer_->response_id(); @@ -626,10 +625,10 @@ class AppCacheURLRequestJobTest : public testing::Test { // 2. Use URLRequest to retrieve it. // 3. Cancel the request after data starts coming in. - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::VerifyCancel)); - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::VerifyCancel)); + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); writer_.reset(service_->storage()->CreateResponseWriter(GURL())); written_response_id_ = writer_->response_id(); @@ -654,10 +653,10 @@ class AppCacheURLRequestJobTest : public testing::Test { // 2. Use URLRequest to retrieve it. // 3. Cancel the request after data starts coming in. - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::VerifyCancel)); - PushNextTask(method_factory_.NewRunnableMethod( - &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::VerifyCancel)); + PushNextTask(NewRunnableMethod( + this, &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); writer_.reset(service_->storage()->CreateResponseWriter(GURL())); written_response_id_ = writer_->response_id(); @@ -671,7 +670,6 @@ class AppCacheURLRequestJobTest : public testing::Test { // Data members -------------------------------------------------------- - ScopedRunnableMethodFactory<AppCacheURLRequestJobTest> method_factory_; scoped_ptr<base::WaitableEvent> test_finished_event_; scoped_ptr<MockStorageDelegate> storage_delegate_; scoped_ptr<MockAppCacheService> service_; @@ -744,3 +742,10 @@ TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) { } // namespace appcache +// AppCacheURLRequestJobTest is expected to always live longer than the +// runnable methods. This lets us call NewRunnableMethod on its instances. +template<> +struct RunnableMethodTraits<appcache::AppCacheURLRequestJobTest> { + void RetainCallee(appcache::AppCacheURLRequestJobTest* obj) { } + void ReleaseCallee(appcache::AppCacheURLRequestJobTest* obj) { } +}; |