summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-14 11:35:50 +0000
committermbelshe@chromium.org <mbelshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-14 11:35:50 +0000
commitf372854526488f35abafb99ec89fc4e5e2251ff1 (patch)
treed9d7070a1f4467596a0a41eda228e735ffc7bc6d
parentd92bfe226c8991c8f32227ac3d49a52a5c02a98f (diff)
downloadchromium_src-f372854526488f35abafb99ec89fc4e5e2251ff1.zip
chromium_src-f372854526488f35abafb99ec89fc4e5e2251ff1.tar.gz
chromium_src-f372854526488f35abafb99ec89fc4e5e2251ff1.tar.bz2
There was a pre-existing bug in the AppCacheUpdateJobTest where it was not
closing out classes created on the IO Thread on the IO Thread. This didn't cause problems before by luck; but now it does. Have the cleanup run on a task on the IO Thread. TBR=michaeln BUG=none TEST=AppCacheUpdateJobTest. Review URL: http://codereview.chromium.org/934002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41547 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/appcache/appcache_update_job_unittest.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/webkit/appcache/appcache_update_job_unittest.cc b/webkit/appcache/appcache_update_job_unittest.cc
index 1c715f0..2ce47b1 100644
--- a/webkit/appcache/appcache_update_job_unittest.cc
+++ b/webkit/appcache/appcache_update_job_unittest.cc
@@ -340,20 +340,32 @@ class AppCacheUpdateJobTest : public testing::Test,
request_context_->AddRef();
}
- static void TearDownTestCase() {
+ static base::WaitableEvent* io_thread_shutdown_event_;
+
+ // Cleanup function; must be called on the IO Thread.
+ static void CleanupIOThread() {
http_server_->Release();
http_server_ = NULL;
- delete io_thread_;
- io_thread_ = NULL;
request_context_->Release();
request_context_ = NULL;
+ io_thread_shutdown_event_->Signal();
+ }
+
+ static void TearDownTestCase() {
+ io_thread_shutdown_event_ = new base::WaitableEvent(false, false);
+ io_thread_->message_loop()->PostTask(FROM_HERE,
+ NewRunnableFunction(CleanupIOThread));
+ io_thread_shutdown_event_->Wait();
+ delete io_thread_shutdown_event_;
+ delete io_thread_;
+ io_thread_ = NULL;
}
// Use a separate IO thread to run a test. Thread will be destroyed
// when it goes out of scope.
template <class Method>
void RunTestOnIOThread(Method method) {
- event_ .reset(new base::WaitableEvent(false, false));
+ event_.reset(new base::WaitableEvent(false, false));
io_thread_->message_loop()->PostTask(
FROM_HERE, new WrapperTask<Method>(this, method));
@@ -2899,6 +2911,8 @@ class AppCacheUpdateJobTest : public testing::Test,
base::Thread* AppCacheUpdateJobTest::io_thread_ = NULL;
HTTPTestServer* AppCacheUpdateJobTest::http_server_ = NULL;
TestURLRequestContext* AppCacheUpdateJobTest::request_context_ = NULL;
+base::WaitableEvent* AppCacheUpdateJobTest::io_thread_shutdown_event_ = NULL;
+
TEST_F(AppCacheUpdateJobTest, AlreadyChecking) {
MockAppCacheService service;